Having some problems getting $1, $2 to work for me in a replace command. Need to fix up a long list of names where the middle name is jammed up against the surname, e.g. "Lee HarveyOswald". Seems that the cleanest way to do this would be to run a Replace command to find all instances of a lower case letter sitting next to (without a space in between) an upper case letter, and getting the script to add a space.
When I use the perl pattern option in Replace, and put
[a-z][A-Z]
as the input, and
$1 $2
as the output, I get an error message saying "$1 is not a valid subexpression identifier ..."
And yet if I only have one input variable (say [a-z]) and put $0 as the output, it works fine. Seems that it's only the fact that there are two or more input variables that is causing the problem. I tried the Old Egrep pattern option also and hit the same problem.
What am I doing wrong ?
TP: Perl expression problem with $0, $1, $2
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
-
- Posts: 20
- Joined: Fri Jun 05, 2009 11:11 pm
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: TP: Perl expression problem with $0, $1, $2
You need to use:
otherwise the letters are not captured.
Code: Select all
([a-z])([A-Z])
-
- Posts: 20
- Joined: Fri Jun 05, 2009 11:11 pm
Re: TP: Perl expression problem with $0, $1, $2
Ahhh... Perfect. Many thanks.