Page 1 of 1

this regex does not seem to work

Posted: Fri Sep 04, 2009 12:27 pm
by mark279455
Hi,
I am not an expert (by any means) here.
I am trying to create a regex to find a bracketed year e.g. (1967)
I have several that work OK when used within java code, but do not work inside textpad.


1. ([(]\d{4}[)])
2. \(\d\d\d\d\)
3. \(\d{4}\)

They are not the most sophisticated or efficient, but as far as I can see should be OK.

Thanks

Mark

Posted: Fri Sep 04, 2009 12:47 pm
by ben_josephs
Use Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
The regex \d isn't accepted by TextPad. Use [0-9] instead.

Also, you don't need the outer parentheses in the first example.

So any of these will work:

1. [(][0-9]{4}[)]
2. \([0-9][0-9][0-9][0-9]\)
3. \([0-9]{4}\)

Edit: Corrected typo.

Posted: Fri Sep 04, 2009 12:54 pm
by mark279455
Ben, - thats great.

thanks

Mark