PDI&x27;s";替换为“字符串”;使用regex执行替换两次
我试图做的只是将参数连接到我现有的字符串“/executable.sh”,这样输出行集就会像这样PDI&x27;s";替换为“字符串”;使用regex执行替换两次,regex,string,pentaho,pdi,Regex,String,Pentaho,Pdi,我试图做的只是将参数连接到我现有的字符串“/executable.sh”,这样输出行集就会像这样 ./executable.sh argument1 ./executable.sh argument3 ./executable.sh argument2 ... ... 下面是“字符串替换”步骤。 搜索设置为(.*)。替换字段设置为./executable.sh$1 我得到的结果是: ./executable.sh argument1./executable.sh ./executa
./executable.sh argument1
./executable.sh argument3
./executable.sh argument2
...
...
下面是“字符串替换”步骤。
搜索设置为(.*)。替换字段设置为./executable.sh$1
我得到的结果是:
./executable.sh argument1./executable.sh
./executable.sh argument2./executable.sh
./executable.sh argument3./executable.sh
为什么要在替换的末尾添加初始字符串
谢谢。这里的问题是您的正则表达式可以匹配在字符串之后匹配的空/空字符串(即后台引擎将字符串拆分为两部分:所有字符和终止的空字符串,因此您可以得到两个替换的匹配项) 为了避免这种情况,您需要使用
(.+)
或
(.+)
模式匹配除换行符以外的1个或多个字符,^(.*)$
从字符串的开头(^
)到结尾($
)匹配除换行符以外的0个或多个字符。第二种模式中的显式锚点有助于避免匹配输入末尾的空字符串。哦,我想您只需要使用(.+)
或^(.*)$
。您是对的。如果你想回答这个问题,我很乐意接受。谢谢
^(.*)$