Help please, how can exclude the presence of a string if a certain word is present in it.
Example:
any text here my text any text word wrong any text
any text here my text any text true any text
any text here my text any text wrong any text
This regex marks all lines ( https://regex101.com/r/rrgEp6/1 ):
here([a-z, ]{0,70})((?:(?! word))) (wrong|true)
It is required to exclude in this case the word - "word":
any text here my text any text true any text
any text here my text any text wrong any text
You may use
here((?:(?!\bword\b)[a-z ,]){0,70}) (wrong|true)
See the regex demo
Details
here
- a string ((?:(?,\bword\b)[az,]){0,70})
- Group 1: a lowercase letter, space or comma, 0 to 70 occurrences, that does not start a word
as a whole word char sequence
- space (wrong|true)
- Group 2: wrong
or true
char sequences.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.