Page 1 of 1

Substitution or Expression

Posted: Sat Feb 21, 2009 2:06 am
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

Posted: Sat Feb 21, 2009 4:17 am
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
-----------------------------------------

Posted: Sat Feb 21, 2009 4:34 am
by George Musick
Making the substitutions in the pop-up Search/Replace menu it says:

Cannot find regular expression

'^([0-9]{3})(.*) '

Posted: Sat Feb 21, 2009 11:33 am
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.)

Posted: Wed Mar 18, 2009 7:30 am
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!