ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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):
I don't know if Emacs supports this, but some regex flavors let you put a "?" after a "*" or "+" to make it lazy instead of greedy (that is, it will match as little text as possible). Here is an example:
Code:
\$_POST\['.*?'\]
Quote:
Originally Posted by grail
I would have thought you might need to escape the first and last square bracket??
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.
Did you try any of your first examples without the extra character after the asterisk?
Code:
\$_POST\['[^]*?']
# so just have
\$_POST\['[^]*']
Hi grail
Yip, I tried
Code:
\$_POST\['[^]*']
and also
Code:
\$_POST\['[^]*'\]
and
Code:
\$_POST\['[^]*'\]]
but like the rest, the first two only matches
$_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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.