您可以使用此言论:
/(?<=(^|>)[^<>]*)\btext\b/g
说明:
(?
大于符号&gt;
[^&lt;&gt;]*
- 随后零或更多任何字符的零或更多不为&lt;&gt;
)
- 在 \ btext \ b
后面的结尾
- 匹配一个单词折断是
text
和另一个单词break,
它使用 global
标志。
现在,用 xxxx
或其他任何代替。
您可以在这里看到它:
您似乎在第一个片段中有一个凹痕问题。只需将返回数据
语句向左移动以将其从while块中删除。除此之外,您似乎并不清楚您正在观看的条件是什么,以结束循环的执行。 i 推测您要在没有更多值附加到行列表的值之后立即返回数据。如果是这样,那么这可能是一个解决方案:
def recordData(memory_service):
""" Record the data from ALMemory.
Returns a matrix of values
"""
print "Recording data ..."
data = list()
# while program is running, record data
print "4"
kickCall()
while True:
print "5"
line = list()
for key in ALMEMORY_KEY_NAMES:
print "6"
value = memory_service.getData(key)
line.append(value)
print "7"
if len(line) == 0:
break
data.append(line)
return data
当心条件语句如果Len(line)== 0:
也可以将其重写为,如果不是line:
。我之所以选择第一份表单仅是为了清楚性:我们正在评估 line
列表中的元素数量是否为零,而不是name line
引用的值。评估为真或错误。
根据Marko Nikolovski的说法,
这里的答案是Objective-C答案:
- (void)ViewDidLoad {
[self addDoneButtonOnKeyboard];
}
- (void)addDoneButtonOnKeyboard {
UIToolbar *toolBarbutton = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
toolBarbutton.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonAction)];
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:barBtnItem];
[items addObject:done];
toolBarbutton.items = items;
[toolBarbutton sizeToFit];
self.timeoutTextField.inputAccessoryView = toolBarbutton;
}
- (void)doneButtonAction {
[self.view endEditing:YES];
}
css只能向下穿越,孩子永远不会对其样式应用
父/上一个兄弟姐妹。
因此,最好的情况是将 .Section-Body
作为第一个孩子并隐藏每个兄弟姐妹。它不会隐藏节
.section-body:empty ~ * {
display: none;
}
<section>
<div class="section-body">
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
</div>
<h1>This will not be hidden</h1>
</section>
<section>
<p>Down side siblings can't be selected</p>
<div class="section-body"></div>
<h1>This will be hidden</h1>
</section>
<section>
<div class="section-body">
</div>
<p>Having new line is not empty</p>
</section>
<section>
<div class="section-body"></div>
<h1>This will be hidden.</h1>
</section>
让我们的“ Little Hack ”, .Section-Body:empty〜 *
将选择每个:empty 具有class section> section-body
的标签,我们可以使用〜)和使用*将选择所有这些。
Cons:
- You need to change structure
- If you have new lines, spaces or anything , this will not be empty
So a betther solution is to use javascript
And here is simple vanilla <强> JavaScript 解决方案
document.querySelectorAll("section > .section-body").forEach(function (el) {
if (el.textContent.trim() === '') {
el.parentNode.style.display = "none";
}
});
<section>
<h1>TITLE</h1>
<div class="section-body">
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
</div>
</section>
<section>
<h1>TITLE 2</h1>
<div class="section-body">
</div>
</section>
您可以使用以下行。
first, *middle, last = fullnames.split()
在for循环中,您将CCI_Words投入到下行中的列表中,因此您的程序第二次通过循环进行迭代后会丢弃错误,并尝试在CCI_Words上调用Lower()。
cci_words = [ ele.strip() for ele in words ]
如果您希望列表中的任何单词返回true,您似乎使这个问题很复杂,可以做这样的事情。
def words_in_url_list(words: List[str], url_list: List[str]) -> bool:
count = 0
for word in words:
word = word.lower()
[count += 1 for url in url_list if word in url]
return count > 0
如果您想检查列表中的所有单词,可以尝试此方法。
def all_words_in_url_list(words: List[str], url_list: List[str]) -> bool:
comparison: set[str] = set()
for word in words:
word = word.lower()
[comparison.add(word) for url in url_list if word in url]
return len(words) == len(comparison)
您无需安装Postgres依赖项。您只需要在app-config.yaml中正确配置Postgres即可。
正如错误所说的那样,未经授权
。
您没有为Avro Serde配置提供身份验证设置。
注意” 。您给出的其余链接似乎是“本地开发 /入门”,并且不
同样涵盖安全配置,您需要 properties < / code>变量中的SASL属性才能连接到实际经纪人,假设这不是
streams.properties
文件...
汇合云需要身份验证,该设置的值应在群集仪表板中显示。
如果没有身份验证,任何人都可以在您的问题中复制代码并开始发送/消费随机数据;)
您仍然在“ C”样式阵列方面思考太多。
您可能想浏览 https://www.learncpp.com/ 学习一种更现代的方法C ++。
通过这种方法,您的代码看起来更像是这样:
#include <stdexcept>
#include <iostream>
#include <vector>
#include <string>
// use std::vector instead of "C" style arrays, they keep track of memory managment AND size of the arrays
// the const's ensure the function cannot modify the input arrays
// the reference (&) ensures the input arrays are not copied.
std::vector<std::string> merge(const std::vector<char>& char_values, const std::vector<int>& int_values)
{
// check your input, merging doesn't make sense if arrays are not of the same length
if (int_values.size() != char_values.size()) throw std::invalid_argument("arrays do not have equal size");
std::vector<std::string> merged_array;
merged_array.reserve(int_values.size());
// use cbegin instead of begin
// these iterators should constant to not change the input arrays
auto int_it = int_values.cbegin();
auto char_it = char_values.cbegin();
for (; int_it != int_values.cend(); ++int_it, ++char_it)
{
// *char_it is the character
// std::to_string converts integer to std::string
// the + operator merges them togehter
// the result is a temporary std::string (not visible to you)
// emplace_back can efficiently put this temporary into the vector
merged_array.emplace_back(*char_it + std::to_string(*int_it));
}
// by using std::vector you also don't have to use a 3rd char** argument
// making it much more clear who owns the memory
// and you can just return an object!
return merged_array;
}
int main()
{
std::vector<char> char_values{ 'a', 'b', 'c' };
std::vector<int> int_values{ 1,2,3 };
auto merged_values = merge(char_values, int_values);
// range based for loops are a safe way to loop over vectors
for (const auto& value : merged_values)
{
std::cout << value << "\n";
}
return 0;
}
可以使用 AnchorPreference
以一种更轻松的方式来完成此操作,那么您只需要一个偏好,并且无需使用 coordinatespace
。
我已经更新了您的代码以使用此信息。它解决了您所遇到的问题,只需注意,它不会将当前滚动到旋转时滚动的项目重新中心,但是如果由于旋转而更改,它确实会更改选择。
struct ContentView: View {
// MARK: - Private Vars
@State private var selectedNumber = 0
private let rectangleHeight: [CGFloat] = [
CGFloat.random(in: 500..<2000),
CGFloat.random(in: 500..<2000),
CGFloat.random(in: 500..<2000),
CGFloat.random(in: 500..<2000),
CGFloat.random(in: 500..<2000)
]
private let colors: [Color] = [
.blue,
.red,
.green,
.gray,
.purple
]
// MARK: - View
var body: some View {
ScrollViewReader { reader in
ScrollView(.horizontal) {
HStack {
ForEach(0..<5) { index in
item(atIndex: index)
}
}
}
.overlayPreferenceValue(ItemLeadingPreferenceKey.self) { anchors in
GeometryReader { proxy in
// Find the index of the last anchor for which the x value is <= 0
// (indicating that it scrolled passed the beginning of the view)
let index = anchors.lastIndex(where: { proxy[$0].x <= 0 }) ?? 0
// Use this index to update the selected number
Color.clear
.onAppear {
selectedNumber = index
}
.onChange(of: index) {
selectedNumber = $0
}
}
.ignoresSafeArea()
}
footer(for: reader)
}
}
// MARK: - Utils
@ViewBuilder
private func item(atIndex index: Int) -> some View {
Rectangle()
.fill(colors[index])
.frame(width: rectangleHeight[index], height: 200)
.id(index)
.background {
GeometryReader { proxy in
// Use the leading of this view for offset calculation
// You can also use center if that makes more sense for selection determination
Color.clear
.anchorPreference(key: ItemLeadingPreferenceKey.self, value: .leading) { [$0] }
}
}
}
@ViewBuilder
private func footer(for proxy: ScrollViewProxy) -> some View {
HStack {
ForEach(0..<5) { index in
ZStack {
if index == selectedNumber {
Rectangle()
.frame(width: 30, height: 30)
}
Rectangle()
.fill(colors[index])
.frame(width: 25, height: 25)
.onTapGesture {
withAnimation {
proxy.scrollTo(index, anchor: .leading)
}
}
}
}
}
}
}
struct ItemLeadingPreferenceKey: PreferenceKey {
static let defaultValue: [Anchor<CGPoint>] = []
static func reduce(value: inout [Anchor<CGPoint>], nextValue: () -> [Anchor<CGPoint>]) {
value.append(contentsOf: nextValue())
}
}
打开开发人员工具并执行以下行:
String.prototype.match = ()=>true
window.onbeforeunload = function(e) {return "Do you want to exit this page?";}
之后永远不会失败,ARN验证
您正在尝试无需使用PHP包装即可直接在命令行上执行PHP,因此Bash Shell试图执行它并且无法识别PHP功能。
您需要在PHP文件中运行 shell_exec()
或使用适当的PHP CLI语法。例如,您可以将 -r
传递到 php
命令,该命令允许您运行代码。
myusername:~$ php -r 'echo shell_exec("pwd");'
/home/myusername
myusername:~$
或者,您可以使用内置的替补。
myusername:~$ php -a
Interactive shell
php > echo shell_exec('pwd');
/home/myusername
php >
另请注意,此处的使用 Echo
,因为成功的结果将返回我们想要看到的字符串。
不要损害已经给出的答案,而是要注意跑到这个的人……
编辑:从那以后,我写了一个博客,讲述了如何在c#中创建Maui UI
Not to detract from the answer already given, but a couple of points to note for people running into this...
EDIT: I have since written a blog on how to write your UI in C# Creating MAUI UI's in C#
.NET MAUI:如何在结合中引用颜色?