In pnotepad it has a regular expression replace feature.
What I want to do is replace all spaces inside of POST variables with underscores.
For example, lets say I have a post variable named $_POST['Apples And Pears']
.
I am trying to figure out the regex replace to turn it into $_POST['Apples_And_Pears']
.
Any help would be awesome, I know how to do this with ALL spaces, but not the spaces that are only inside POST variables.
I need this because I have a LOT of POST variables inside a PHP file that I need to perform this operation on.
I'm not sure about pnotepad's syntax, but from a cursory glance it looks like pnotepad adheres to PCRE, so replace this:
((?<=\$_POST\[[^[]*) )
with this:
_
(I added an unnecessary set of parentheses just to show the space at the end.)
This uses a positive lookbehind assertion to say, "If I am a space character and behind me is a string of non-[
characters preceded by $_POST[
, then replace me."
If this doesn't work, the problem is probably that, like many engines, pnotepad doesn't support arbitrary-length lookbehind assertions. In that case, you'll have to replace this:
(?:(\$_POST\[[^[]*) )
with this:
$1
and manually keep replacing over and over until no more replacements can be made.