I have the following string:
$foo = "'fdsfdsf', 'fsdfdsfdsfdsfds fdsf sdfd f sfs', 'fsdfsdfsd f' fdfsdfdsfdsfsf";
I want to get everything between ' ' but from first to last occurrence.
I have tried to search my string by /.*('.*').*/ but only 'fdsfdsf' was taken, how to turn on greedy or something like that?
Try
This will give you the strings enclosed in single quotes within each field in the string.
Of course, the quotes need to be balanced, and the regex match will be thrown off by escaped quotes in your string, so if those may occur, the pattern needs to be modified.
For example,
would work if quotes can be escaped with backlashes.