如果单词出现在匹配之前,如何忽略基于单词的匹配
How to ignore a match based on a word if it appears before the match
我有如下内容
Payment Instrument modified. payment no: 5000000000000000, method: C for transponder: 5000000000000000 transponder type: A
在上面我的正则表达式只需要匹配 payment no:
之后出现的 5000000000000000
模式:([payment no: ][0-9]{4}[0-9]{0,16})([0-9]{4})
您可以使用 RegEx (?<=payment no: )\d+
(?<=payment no: )
确保在匹配之前有 payment no:
\d+
匹配任意数字 1 次或多次。
没有后视的版本将是 payment no: (\d+)
我有如下内容
Payment Instrument modified. payment no: 5000000000000000, method: C for transponder: 5000000000000000 transponder type: A
在上面我的正则表达式只需要匹配 payment no:
模式:([payment no: ][0-9]{4}[0-9]{0,16})([0-9]{4})
您可以使用 RegEx (?<=payment no: )\d+
(?<=payment no: )
确保在匹配之前有payment no:
\d+
匹配任意数字 1 次或多次。
没有后视的版本将是 payment no: (\d+)