User Tools

Site Tools


regex:all_text_not_containing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
regex:all_text_not_containing [2025/05/27 07:45] peterregex:all_text_not_containing [2025/05/27 07:55] (current) peter
Line 38: Line 38:
 ^([^a]|a($|[^b]|b($|[^c]|c($|[^_])))).* ^([^a]|a($|[^b]|b($|[^c]|c($|[^_])))).*
 </code> </code>
 +
 +----
 +
 +===== Match strings that do not end in particular sequence =====
 +
 +Use a negative lookbehind assertion:
 +
 +<code bash>
 +^[/\w\.-]+(?<!\.html)$
 +</code>
 +
 +or, use a lookahead:
 +
 +<code bash>
 +^(?!.*\.html$)[/\w\.-]+$
 +</code>
 +
 +or, another use of a lookahead assertion:
 +
 +<code bash>
 +/((?!\.html$)[/\w.-])+/
 +</code>
 +
 +<WRAP info>
 +**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.
 +
 +
 +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>
 +/^((?!\.html$)[/\w.-])+$/
 +</code>
 +
 +
 +</WRAP>
 +
  
 ---- ----
regex/all_text_not_containing.1748331935.txt.gz · Last modified: 2025/05/27 07:45 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki