Help with a regular expression

I wonder if I may ask for some help with a regular expression. The list I am trying to sort is:

A. Culling Jnr
J. & K. Taylor
W. Dodd
K. Smith
Clough Family
G. Grieve
S. & D. Phipps
A. L. Newnham
J. & D. Elms
R. Henson
D. G. Quinn
K. Shields
R. & L. Hammer
Brooks Family
C. Reid
R. Price

I have this for my regular expression:


and my replacement is:

\1, \2

This results in:

Culling Jnr, A.
Taylor, J. & K.
Dodd, W.
Smith, K.
Clough Family
Grieve, G.
Phipps, S. & D.
L. Newnham, A.
Elms, J. & D.
Henson, R.
G. Quinn, D.
Shields, K.
Hammer, R. & L.
Brooks Family
Reid, C.
Price, R.

If works for nearly everything, except where a person has two initials. I have spent hours playing with my search pattern, and I just can’t seem to resolve my problem.

Any help would be gratefully received.

Try this:

^(\\w\\.(?: &)?(?: \\w\\.)?) (.+)$

Once again WOW!!

Thank you very much, Kem.

May I ask what the (?: is doing?

Also, Xojo regex is the same as Perl, is that correct?

code[/code] means a non-capturing group. If you had the text “ABC” and used the pattern code(b)©[/code], you’d end up with three subgroups (in Xojo, SubExpressionString). But the pattern code(?:b)(?:c)[/code] would yield no subgroups.

It’s a way to group a subpattern without capturing it.

Xojo uses the PCRE library, or Perl Compatible Regular Expressions, so it’s mostly like Perl, but also recognizes some conventions from other implementations like Python.

Thanks once again Kem. I can’t remember any other forum I have been on where I am learning (and have learned) so much.