RegEx Help

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

RegEx Help

Post by SteveH »

I am using a regular expression to remove some dates from a file. I want to make the following change:

Code: Select all

/Title (19/04/2005DMG Document Review)
becomes...

Code: Select all

/Title (DMG Document Review)
The regular expression starts \/Title \([:digit:] but I am finding that it matches strings beginning...

Code: Select all

/Title (G
and skipping those that start with a date.

Using \/Title \([0-9] only the digts are captured.

Am I being a bit silly and [:digit:] is not numbers?

POSIX Regular Expression syntax is enabled.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You need [[:digit:]], not [:digit:], which finds any of the characters: :, d, i, g, t !

BTW, you don't need to escape slashes.
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

Thanks for that. With that pointer I just spotted the (Note the extra pairs of brackets in the help file. It now works as advertised.

I have removed the superfluous escape characters but will stick with [0-9] as it saves me 18 characters in the search string.

Cheers

(This is all to strip out dates from automatically generated PDF bookmarks. Now that it is a TP macro, it runs in seconds and saves hours of work. Good result!)
Post Reply