Question

I have a string like this:

('Afghanistan','3',''),(' Albania','1','90 days'),(' Algeria','3',''),(' Andorra','3',''),(' Angola','3','')... etc

I need to select spaces after: ),('

Can someone help me plz?

Was it helpful?

Solution

Why regexp? Just use str_replace("),(' ","),('", $myString);

edit: ),(' was per your request. But I advise you to only look for (', because the very first entry might also contain a space, but isn't caught with the string you requested.

So use str_replace("(' ","('", $myString);

OTHER TIPS

Assuming you have described your input perfectly, this should do the trick.

(?<='\),\(') *

You can use this :

$pattern = "~(?<=\Q),('\E) ~";

all between \Q and \E are seen as literals.

(?<=.....) means preceded by

Just try with following regex:

/\),\('( )/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top