Regex question (multi-line)

Tool for Search and Replace across multiple files.
Post Reply
User avatar
Juergen

Regex question (multi-line)

Post by Juergen »

In the Tester, 100 items are shown in the 'Elements Found' window, no matter what the setting is in Options.

In the tester each occurance is a new line, in the TC multiple occurances can be on one line. Could there be an option to show each occurance on a separate line?

How do I find something across multiple lines? I want to find all occurances of brackets including the enclosed text. Sample text:
quote:
Regex test file
for brackets plus contents.
Notes within[Note_1] text, notes at
[Note_2]start or
end of line,[Note_3]
notes by itself on line,
[Note_4]
also[Note_5] multiple[Note_6] notes[Note_7] per line
and finally
[Note_8
over two lines]
or notes over multiple
lines[Note_9 on
three
lines] within text.
un-quote

The best I can come up with is this rather simple regex \[.*?\] which gives me all notes except the two last ones over multiple lines. Any suggestions?

User avatar
DV

Post by DV »

- The 100 limit is hardcoded into the Tester (this will be linked to an option in future versions)
-I'll look into optional views- interesting idea.

Try this -
\[[\s\S]*?\]

This uses [\s|\S] instead of the dot - the dot won't match over newlines but this will (it means "any character that�s either whitespace or not whitespace".)
User avatar
Juergen

Post by Juergen »

Thanks for your prompt response and for the regex. I started looking into regexes when I stumbled across your TC just a little time ago, so am less than a regex novice. Did I tell you before a very, very nice program?
One more question: what should the regex be if I would want to 'replace with nothing' and would want to replace any new lines in brackets as well?

If you are considering optional views, can we also have an option, with hits highlighted, of course, of (a) showing whole lines where there is a match and (b) showing all text. Currently only lines with a match are shown. Increasing max. characters 'after' is not a work-around. And this option would apply to TC and the tester.

In the tester, each element is numbered. Can we have an option where the individual number is not shown, so hits can be copied without the numbers?
User avatar
Juergen

Post by Juergen »

Ehh, ...
please ignore my last regex request. Your regex does include new lines. Sorry.
Post Reply