User Tools

Site Tools


regex:all_text_not_containing

This is an old revision of the document!


Regex - All Text Not Containing

Text that does not contain ~

[^~\x22]+

Match anything except \n

.*

Match strings that do not start with a sequence

Ignore strings that start with the label “abc_”.

Use a negative look-ahead assertion:

^(?!abc_).+

Or, use a negative look-behind assertion:

(^.{1,3}$|^.{4}(?<!abc_).*)

Or, use plain old character sets and alternations:

^([^a]|a($|[^b]|b($|[^c]|c($|[^_])))).*

Match strings that do not end in particular sequence

Use a negative lookbehind assertion:

^[/\w\.-]+(?<!\.html)$

or, use a lookahead:

^(?!.*\.html$)[/\w\.-]+$

or, another use of a lookahead assertion:

/((?!\.html$)[/\w.-])+/

NOTE:

  • ( - Start a group for the purposes of repeating.
  • (?!\.html$) - Negative lookahead assertion for the pattern /\.html$/.
  • [/\w.-] - The pattern for matching a URL character.
  • )+ - Repeat the group.

References

regex/all_text_not_containing.1748332404.txt.gz · Last modified: 2025/05/27 07:53 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki