Grouping

The requirement is to search for text between braces { }. But the search is over line endings. The braces we are searching for may be at the starts of lines.

If you wish to experiment, there are two such occurrences in the sample text. Can you find them?

Search $ "{" ** $ "}"
This fails to find the second occurrence because there is no } after the end of the first line (i.e at the start of the next line). ** scans forward in the text to the first $. But in the second example there is no } starting the next line, so the match fails.

Search $ "{" ** ($ "}")
This finds both occurrences because } will be matched even when it is several lines past the starting { because ** searches forward in the text until $ "}" is found - i.e } at the start of a line, so immediately after $

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/group.html
Page first published
Last modified:Wed, 06 Mar 2019 19:14:30 GMT
© 2017 - 2024 Richard Torrens.