regex:all_text_not_containing
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
regex:all_text_not_containing [2022/09/20 23:28] – peter | regex:all_text_not_containing [2025/05/27 07:55] (current) – peter | ||
---|---|---|---|
Line 16: | Line 16: | ||
---- | ---- | ||
+ | |||
+ | ===== Match strings that do not start with a sequence ===== | ||
+ | |||
+ | Ignore strings that start with the label " | ||
+ | |||
+ | Use a negative look-ahead assertion: | ||
+ | |||
+ | <code bash> | ||
+ | ^(?!abc_).+ | ||
+ | </ | ||
+ | |||
+ | Or, use a negative look-behind assertion: | ||
+ | |||
+ | <code bash> | ||
+ | (^.{1, | ||
+ | </ | ||
+ | |||
+ | Or, use plain old character sets and alternations: | ||
+ | |||
+ | <code bash> | ||
+ | ^([^a]|a($|[^b]|b($|[^c]|c($|[^_])))).* | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Match strings that do not end in particular sequence ===== | ||
+ | |||
+ | Use a negative lookbehind assertion: | ||
+ | |||
+ | <code bash> | ||
+ | ^[/ | ||
+ | </ | ||
+ | |||
+ | or, use a lookahead: | ||
+ | |||
+ | <code bash> | ||
+ | ^(? | ||
+ | </ | ||
+ | |||
+ | or, another use of a lookahead assertion: | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE:** | ||
+ | |||
+ | * **(** - Start a group for the purposes of repeating. | ||
+ | * **(? | ||
+ | * **[/\w.-]** - The pattern for matching a URL character. | ||
+ | * **)+** - Repeat the group. | ||
+ | |||
+ | |||
+ | To force it to match the entire string, anchor the entire pattern with **^** at the start and **$** at the end; otherwise it is free to only match a portion of the string. With this change, it becomes: | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== References ===== | ||
+ | |||
+ | https:// | ||
regex/all_text_not_containing.1663716496.txt.gz · Last modified: 2022/09/20 23:28 by peter