Substitution or Expression

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
George Musick
Posts: 5
Joined: Sat Jun 21, 2008 2:19 pm

Substitution or Expression

Post by George Musick »

Hi all,

I get files that need to be converted from:

001 Company A
002 Company BBB
003 Brand 123
004 Brand WXYABC
005 Just any kind of text

to:

(001) Company A^
(002) Company BBB^
(003) Brand 123^
(004) Brand WXYABC^
(005) Just any kind of text^


There might be a few additional spaces at the end of some lines but I still need the "^" to be right after the last character on the line (not counting a space).

Thanks so much,
George
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for: ^([0-9]{3})(.*)
Replace with: \(\1\)\2^

Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Hope this was helpful.............good luck,
Bob
George Musick
Posts: 5
Joined: Sat Jun 21, 2008 2:19 pm

Post by George Musick »

Making the substitutions in the pop-up Search/Replace menu it says:

Cannot find regular expression

'^([0-9]{3})(.*) '
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Make sure you are using Posix regular expression syntax, as Bob specified in his instructions:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
and remove the space that got added to the end of the regular expression when you copied it.

If the length of the number might be different from 3, use
Find what: ^([0-9]+)(.*)
Replace with: (\1)\2^
(You don't need to quote parentheses with a backslash in the replacement expression.)
George Musick
Posts: 5
Joined: Sat Jun 21, 2008 2:19 pm

Post by George Musick »

Sorry for the late response.

Ben - your suggestion worked fine. I still could not get Bob's to work though.

Thanks for the help!
Post Reply