Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 匹配字符串,以特定标记开头的行除外_Regex_Search_Xliff - Fatal编程技术网

Regex 匹配字符串,以特定标记开头的行除外

Regex 匹配字符串,以特定标记开头的行除外,regex,search,xliff,Regex,Search,Xliff,我不是程序员,所以如果我的问题有点太基本,我道歉 我是一名翻译,有一份xliff(出于我们的目的,纯文本)文档,其结构大致如下: <source>For workers in the rest of the state, the minimum wage will increase to $9.70 at the end of 2016, then another .70 each year after until reaching $12.50 on 12/31/2020 – af

我不是程序员,所以如果我的问题有点太基本,我道歉

我是一名翻译,有一份xliff(出于我们的目的,纯文本)文档,其结构大致如下:

<source>For workers in the rest of the state, the minimum wage will increase to $9.70 at the end of 2016, then another .70 each year after until reaching $12.50 on 12/31/2020 – after which the minimum wage will continue to increase to $15 on an indexed schedule.</source>
<target>Для работников остальной части штата минимальная ставка оплаты труда поднимется до $9,70 в конце 2016 года, а затем будет расти на $0,70 ежегодно, достигнув размера в $12,50 31 декабря 2020 года, после чего минимальная ставка будет продолжать повышаться до $15 на основании графика.</target>
<source>.*?</source>\s*<target>\K(?:.*?)(\$\d+(?:(?:\.|,)\d{2})?)|((?1))
它返回所有美元金额,包括
段中的金额。基于我在这里的搜索,我尝试使用lookbehinds排除这些,但未能获得所需的结果。我不会和你分享我失败的尝试

实现这一目标的好方法是什么


谢谢大家!

好吧,这很棘手。很容易将文本中的美元金额与以下内容匹配:

(\$\d+(?:(?:\.|,)\d{2})?)
但是如果您只想在某个点之后匹配,您可以匹配它之前的内容,然后使用
\K
将其丢弃。因此,这将匹配所有
源代码
内容和开头的
目标标记:

<source>.*?</source>\s*<target>\K
希望这能让你走上正确的方向

<source>.*?</source>\s*<target>\K(?:.*?)(\$\d+(?:(?:\.|,)\d{2})?)|((?1))