Hi,
I need an extremely simple regex pattern that matches anything within square brackets [].
Example:
Code:
This is a [test] text with [some] [examples].
Required results: [test], [some], [examples].
I don't want to get rid of the brackets, they should be included in the result (that should make it easier, right?)
If possible I'd like to exlude results that have whitespace in them, so things like [this string] should not be matched. If that gets too hard (probably not, but hey I can't even manage this :S) then I don't really mind, I can always check if the result contains whitespace myself.
I tried a lot of examples I could find online and ones that I could think of myself but none work. Note: I've been testing with the Visual Studio Find dialog (checking to use regular expressions obviously), maybe that's where the problem lies, because I don't really understand why some of these don't work...
Anyway, first thing I tried was simple: match the two brackets and one or more characters in between (that should be a +, right?)
No results in a file containing multiple of [these] strings...
Then I tried like a dozen others, some of which according to VS contained errors and some failed to match anything.
The closest I got was using
But, that also matches strings that span multiple 'parts'.
Example:
Code:
Hello, [my] name [is] Nick
here it also matches '[my] name [is]', which is not what I'm looking for....
I don't understand why I suck at regex so much but I just can't find the right pattern, lol... Any help?