Emacs regex headache - replace between ' and ' ??
Hi guys
I have strings that looks like this in Emacs: $_POST['banner_name'] $_POST['banner_alt_text'] $_POST['banner_location_type'] I'm searching for an Emacs regex that will match the whole string, e. g $_POST[' and then any number of characters up to the next '] My problem is how do I "say" to emacs "match up to the next ' "? I so far have \$_POST[' which works but how do I now "say" "from the ' to the second (irrespective of character count) "'" character and then the ] at the end? Thanks! |
Well normal way is to say give me all that is not (I do not know emacs so you may have to play with it):
Code:
\$_POST['[^']*'] |
Quote:
Code:
\$_POST\['.*?'\] Quote:
|
Hi guys
Thanks for the suggestions! I tried the following: Code:
\$_POST\['[^]*?'] $_POST[b Also Code:
\$_POST\['.*?'\] E. g. I've still got the same problem, I can match the fixed parts of the string no problem, but the varying part between the ' ' quotes - how to specify "match any number of characters up to next ' " still eludes me. Thanks for the assistance anyway! |
Did you try any of your first examples without the extra character after the asterisk?
Code:
\$_POST\['[^]*?'] |
Quote:
Yip, I tried Code:
\$_POST\['[^]*'] Code:
\$_POST\['[^]*'\] Code:
\$_POST\['[^]*'\]] $_POST['b and the last is completely invalid - e. g. the two working ones just the first char between the quotes - instead of all the chars between the quotes... E.g. it is the right track, I just need to get it to be "greedy" up to the next ' it encounters. Thanks for the help. Kind regards, |
I just looked back over all examples and realised you are not asking it to look for not an apostrophe??
Code:
\$_POST\['[^]*'] |
Quote:
Your bottommost suggestion worked perfectly. Thank you VERY much for your assistance - I've marked your post as helpful. I'll go back to the Emacs docs now and see what the syntax exactly means - still learning this side. Again, thank you. Keep well Stefan |
Cool ... glad we got there .. don't forget to mark as SOLVED.
|
All times are GMT -5. The time now is 11:14 PM. |