John Davidson

php - REGEX converting $_POST['x'] to $_x

0 comments
Message:


Someone can help me how to make a regular expression to convert all strings like:


$_POST['key']

To:


$_key

This will not be used in the code itself, but I will use it in my IDE, to facilitate a bulk change.


Thanks.



My Answer:
You can use the following regular expression to achieve this conversion:

Find: \$_POST\['(.*?)'\]
Replace: \$_$1

This regular expression will match any string in the format $_POST['key'] and replace it with $_key. Just make sure to enable regular expression search/replace in your IDE when performing the bulk change.

Rate this post

3 of 5 based on 7210 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us