Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got like 6 pages were i get both POST and GET data several times (PHP). I've now made a function that get's the data for me, so instead of typing:


i now type:


The problem i have is that i'm to lazy to replace each $_POST with gpost() (and $_GET with gget(). I know how to do that. But i need to remove the [] braces aswell. Otherwise it'd look like this: gpost(['whatever']), not really what i want.

But looking at the find/replace window in dreamweaver i saw a checkbox labeled "Use regular expressions". Therefore I ask; can someone help me create a regular expression that replaces this:


with this:


The replace window looks like this:

enter image description here

EDIT: I now found a site, but it doesn't seem to work. Here's what i came up with now: trentmueller.com/blog/search-and-replace-wildcard-characters-in-dreamweaver.html





I get this error: unmatched ) in regular expression

share|improve this question
s/\$_POST\['(.*?)']/gpost('$1')/ should work, I believe. The $1 references the first match (The (.*?)), so if dreamweaver uses a different syntax for that you'd need to figure out what that is. –  Phoshi Oct 9 '10 at 13:54
Thanks Phoshi. Is it possible to split that into two expressions somehow? In dreamweaver, there is two fields. Look at the image i posted above. –  Nike Oct 9 '10 at 13:58
Ah, sorry, I forget some people aren't used to that syntax. \$_POST\['(.*?)'] is the "search" (Though the [ needs to be escaped with a \, that doesn't seem to want to appear in the comments, though), and the gpost('$1') is the "replace" –  Phoshi Oct 9 '10 at 14:19
I tried the new expressions you posted, but they doesn't seem to work either. I tried escaping the [] aswell, but that didn't do any difference. I edited my post, maybe you can help me get that to work instead? Thanks once again, appreciate it! –  Nike Oct 9 '10 at 14:29
The one you've copied there isn't working because the class [^&lt;]* matches "any character that isn't &lt; 0 or more times". &lt; doesn't even come into it here. Otherwise, your expression isn't working because [ and ] define a "character class", and you have to escape the [ with a \ to stop it being a character class, and start it matching a literal [. –  Phoshi Oct 9 '10 at 15:34

2 Answers 2

If you need to replace this everywhere, unless I am missing something, there is no need to use Regular Expressions, simply do a regular replace and put $_POST['whatever']; as the find and gpost('whatever'); as the replace.

Change the drop downs to entire site and in source code only.

If you want to use Regular Expressions, Stack Overflow will most likely be your best bet for help, but I think you will be over complicating matters.

share|improve this answer
The point with using regular expressions is to avoid having to do spend hours doing something. As i mentioned earlier, i have several pages with several different both $_POST's and $_GET's. They all have different "keys" in them (i only used "whatever" as an example before..). I could do something like to replace $_GET[' with gget(, but i will run into problems when i need to replace the other side, because further down in the code i have PHP arrays, which also uses [] braces, and i can't replace them... –  Nike Oct 9 '10 at 13:55

You have to escape the meta character, so try:




This works for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.