我想找到并替换一个模式
text="
hold1
hold2
<file option1='one'>
some text
some text
...
... more data
</file>
this1
that1
"
pattern="<file.*</file>"
replacewith="<sometext>
value1
</sometext>"
output text="
hold1
hold2
<sometext>
value1
</sometext>
this1
that1
"
Run Code Online (Sandbox Code Playgroud)
PS Stackoverflow上的这些问题没有帮助. sed:仅当一行与第三个单词或任何模式匹配时,在两个单词之间打印行
如何返回$以外的值?来自ssh会话
例如:
x=5
echo "$x"
ssh -o StrictHostKeyChecking=no root@hostname "x=10"
echo "$x"
Run Code Online (Sandbox Code Playgroud)
这将打印
5
5
Run Code Online (Sandbox Code Playgroud)
但我需要新的价值
5
10
Run Code Online (Sandbox Code Playgroud) 我在这做错了什么?
用于计算前缀函数的Java代码.两个输入是正确的,但最后一个是错误的.
这是伪代码:

Java代码:
class Main {
// compute prefix function
public static void main(String[] args) {
String p = "422213422153342";
String x = "ababbabbabbababbabb";
String y = "ababaca";
printOutput(p);
printOutput(y);
System.out.println();System.out.println();
System.out.println("the prefix func below is wrong. I am not sure why.");
System.out.print("answer should be: 0 0 1 2 0 1 2 0 1 2 0 1 2 3 4 5 6 7 8");
printOutput(x);
}
static void printOutput(String P){
System.out.println();System.out.println();
System.out.print("p[i]: ");
for(int i = 0; i < …Run Code Online (Sandbox Code Playgroud)