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 $

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, 30 May 2018 09:33:42 BST
© 2017 - 2018 Richard Torrens.