Hi,
I seem to be missing a trick here. I have data that looks like this;
1204,Bill Cook, 1205,Dave Smith, 1208,Bill Cook, 1212,Sally Jones, 1211,Bill Cook, 1202,Dave Smith,
Which I want to get looking like this;
1204,Bill Cook
1205,Dave Smith
1208,Bill Cook etc..
I can search using “[a-z]+, “ which finds all the surnames and the following comma & space, but if I try to turn it into a Regex, I come unstuck.
I thought this might work;
Search: \([a-z]+\) \(, \)
Replace \1\n
But the Regex is invalid and I don’t understand why. Can someone advise as to where I’m going wrong?
Many thanks.
Simple Regex is beating me.
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Try this:
Search for
^([0-9]+,[^,]*), ?
Replace with
\1\n
Click "Find Next" repeatedly until you are done (Unfortunately I did not find a better way to do this)
EDIT: I just DID find a better way
Just search for
([0-9]+,[^,]*), ?
(there is a whitespace before the "?", but be sure not to copy the one at the end of the line)
Replace with
\1\n
and click "Replace all"
You have to use Posix Syntax for this to work. (Configure->Preferences->Use POSIX regular expression syntax)
Search for
^([0-9]+,[^,]*), ?
Replace with
\1\n
Click "Find Next" repeatedly until you are done (Unfortunately I did not find a better way to do this)
EDIT: I just DID find a better way
Just search for
([0-9]+,[^,]*), ?
(there is a whitespace before the "?", but be sure not to copy the one at the end of the line)
Replace with
\1\n
and click "Replace all"
You have to use Posix Syntax for this to work. (Configure->Preferences->Use POSIX regular expression syntax)
You need to perform the following search and replace:
Find what:
This works with a replace all and relies on their being a comma in front of each number to avoid the need to repeat the search.
Hope this helps.
Find what:
Replace with:, *([0-9]+),
With regular expression enabled and POSIX regular expression syntax enabled in the general preferences.\n\1,
This works with a replace all and relies on their being a comma in front of each number to avoid the need to repeat the search.
Hope this helps.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm