Exclusive repeat match

This was raised as a problem in the mailing list. The requirement was to match >> and to exclude >>>. Most solutions would find the first two chevrons, or the last two, so in both cases >>> would be found. The actual character matched is unimportant: we will use x to denote it, but remember that certain characters must be escaped in text strings.

Search ( ~"x" .) @0 "xx" ~"x"

This breaks down to
(~"x" .) if first character isn't "x" then match it (to advance the search pointer)
@0 set mark @0 so that the actual match starts here and the preceding character is not coloured in LoF
"xx" literal string to match
next character should not be "x" for match to succeed

Was this page helpful? Please email me and/or rate this page:

If you want a reply make sure any email address @torrens.org will not get spam-binned!
Optional comment

Other relevant pages

Top of page

Page Information

http://css.torrens.org/valid-html401-bluehttp://css.torrens.org/valid-css Document URI: http://stronged.torrens.org/man/search/examples/exclude.html
Page first published
Last modified:Sat, 22 Feb 2020 19:24:46 GMT
© 2019 - 2023 Richard Torrens.