HowTo html input find/replace regex

Whenever I make a form, it’s a bit of a hassle to add in the php support. That is, if the page gets reloaded of sent back, we want to insure that all the valid data that was entered before is maintained.

And easy way to do this is:

Here is an easy way, tested in jedit, but should work with little to no modification in other regex capable editors:
Find: \<input name=”([\w]+)” value=”([\w]+)” />
Replace: <input name=”$1″ value=”<?= isset(\$_POST[‘$1’]) ? \$_POST[‘$1’] : ‘$3’ ?>” />

About Jason

I am a 31 year old programmer living in the south of France. I currently work actively in the fields of Ruby/PHP/Javascript and server/website administration.
This entry was posted in PHP Tutorials, PHP/MySQL and tagged . Bookmark the permalink.