$regexp confusion - problem with escaping?

Hi and thanks for a great program, which i just discovered. It seems to do almost anything.

However i am obviously too thick to understand exactly what needs escaping where.

I want to use the artist tag (which contains multiple artists) to generate the artistsort tag.
I need to handle three cases :-
either a title start in in The, Les etc which should have the , The added at the end
or anything containing a set of names indicating an orchestra which doesnt start as above (symphony, orchestra etc etc) which should be copied as is
or anything else is assumed to be a name to be reversed (John Paul Jones => Jones, John Paul)

It seems i can do all of the three via a replace with regular expression but when i try to combine them into a scripted expression i cant get it to work despite reading a number of posts on escaping and trying a lot of variations over a couple of hours. I therefore throw myself on your mercy..

Just looking at the first case the action
Format Value 'ARTISTSORT': $meta(artist,0)
Replace with Regular Expresion 'ARTISTSORT': "^(the|el|los|la|las|le|les)\s(.*)" =>"$2, $1"

works and replaces "Les Arts Florissants" with "Arts Florissants, Les"

however when I put this in a script
Format Value 'ARTISTSORT': $regexp($meta(artist,0),'^(the|el|los|la|las|le|les)\s(.*)','$2, $1')
I always get "Les Arts Florissants" regardless of using $1 $2 or both.

So please show me what needs to be done to make this work.

for name I would use $regexp($meta(artist,0),'(.) (.)', '$2, $1') which does work

Logically as they are quite similar i need to escape the ^ | or replace the \s with blank, but i think i have tried all combinations without success.

Thanks for any help offered

the $regexp() is case-sensitive. "the" does not match "The"

My specialty - ignoring the obvious - Thanks very much