I have strings that looks like this:
searchUniqueCode("name", "FF14_1451_DAD4");searchUniqueCode("name", "F1F1_1451_DAD4");
searchUniqueCode("name", "FF14_3121_DAD4");searchUniqueCode("name", "SH14_1451_DAD4");
searchUniqueCode("name", "FF14_1131_DAD4");searchUniqueCode("name", "FF14_1451_D31F");
And I am trying to get all of the strings under " " after the common pattern searchUniqueCode("name", Like the FF14_1451_DAD4.
Is there any way I can achieve that using PHP?
Thank you!
>Solution :
Try this regex:
searchUniqueCode\("name",\s*"\K[^"]+
Explanation:
searchUniqueCode\("name",– matchessearchUniqueCode\("name",\s*"– matches 0 or more occurrences of a white-space followed by a"\K– un-matches whatever has been matched so far and starts the match from the current position[^"]+– matches 1 or more occurrences of any character that is not a". This is the desired match that will match everything until the next occurrence of"
Or
You can capture the desired values in group 1 as shown below:
searchUniqueCode\("name",\s*"([^"]+)" – Working code here