这是一个示例字符串。 我需要修复其中的更多内容:
"måde", "answer" => "råd");在此字符串中有2个字符实例å。 我想找到一个匹配使用正则表达式的å在råd ,而忽略了å在måde 。
所以基本上我需要在answer之后找到一个匹配的匹配。
我认为(?<=answer)å(?=\;)会起作用,但我对此非常陌生,如果有人能指出我正确的方向,我会非常感激。
我之前尝试过问这个问题,但由于某种原因而被投票,所以我试着在这里重新制定它。 我希望它足够清楚。
Here is an example string. I have many more of these that I need to fix:
"måde", "answer" => "råd");In this string there are 2 instances of the character å. I want find a match for the å in råd using regex, while ignoring the the å in måde.
So basically I need to find a match of an occurrence of å after answer.
I thought that (?<=answer)å(?=\;) would work, but I'm really new to this and would very much appreciate it if someone could point me in the right direction.
I tried asking this question before but got downvoted for some reason, so I tried to reformulate it here. I hope it is clear enough.
最满意答案
看后面(通常)不能是可变长度,但通过使用负向前看,你告诉它不匹配:
å(?!.*answer)这匹配“å”,但仅在“回答”未出现在其后的某处。
Look behinds (typically) can't be of variable length, but by using a negative look ahead, you tell it what not to match:
å(?!.*answer)This matches "å", but only if "answer" doesn't appear somewhere after it.
更多推荐
发布评论