Page 1 of 1
Find all text between brackets
Posted: 2012-11-13 11:52:12
by Rolfe
Hi, I would like to find all alpha/numeric text between brackets (both types) and then copy it to the clipboard for pasting in to another file. I need just to find, copy and extract the text, not the brackets! Can anyone help?
Thanks in advance.
Re: Find all text between brackets
Posted: 2012-11-14 10:13:49
by martin
Hi Rolfe, this is definitely possible using NWP. Basically you'll want to find and select such text using PowerFind, which uses pattern matching (aka "regular expressions"). The simplest way to do this is to use PowerFind's built-in bubbles, eg:

- Screen Shot 2012-11-14 at 10.10.07 AM.png (29.93 KiB) Viewed 4144 times
There's a few things going on there:
1. The "PrecededBy" and "FollowedBy" bubbles ensure the brackets are matched, but not included in the selection.
2. The "1+ Shortest" means to match multiple "AnyTextCharacter", but to only match the shortest number of them. In this case that means match all such characters until the closing bracket is found.
The corresponding PowerFind Pro regular expression is:
Once you've used either of these patterns, you can "Find All" to select the desired text, copy it, and then paste it wherever you like.
I hope that helps. Please let us know if you have any questions!
Re: Find all text between brackets
Posted: 2012-11-14 10:40:07
by Rolfe
Thanks for the the reply, however that only finds text between square brackets [ ] but not round ( ) or { }. Is it possible to adjust this? Is it possible to copy to the clipboard in that process?
Thanks
Re: Find all text between brackets
Posted: 2012-11-14 13:26:43
by martin
Rolfe wrote:Thanks for the the reply, however that only finds text between square brackets [ ] but not round ( ) or { }. Is it possible to adjust this?
Ah sorry, I didn't understand that you wanted to find text in braces, brackets, and parentheses. Yes indeed this is possible. Here's the PowerFind expression:

- multi.png (27.16 KiB) Viewed 4139 times
And the equivalent PowerFind Pro expression:
That should do it.
Is it possible to copy to the clipboard in that process?
Yes, after you've done a Find All, just use the normal Copy menu/command and all selected matches will be placed on the clipboard.
Re: Find all text between brackets
Posted: 2012-11-14 13:40:31
by Rolfe
Thats perfect, thanks very much.