Find and replace except if string contains charecter
-
I have many documents where I need to “fix” html codes.
When the files were created, some were create using POST[variable] and some were created POST[“variable”'] tags.
I need to convert the POST[variable] tags with POST[“variable”] to standardize the documents and leave the POST[“variable”] tags alone
If I use RegEx POST[(.+)] it finds all instances of POST[] entries (ones without the double quotes and ones withe the double quotes.
Is there a RegEx that will tell it to only find the POST[variable] and to ignore the ones with POST[“variable”]?
Hope this makes sense and someone can assist.
Thanks in advance. -
@Pinto-Islam said in Find and replace except if string contains charecter:
I need to convert the POST[variable] tags with POST[“variable”] to standardize the documents and leave the POST[“variable”] tags alone
If I use RegEx POST[(.+)] it finds all instances of POST[] entries (ones without the double quotes and ones withe the double quotes.
Try:
Find what :POST\[([^"\]]++)\]
Replace with :POST["\1"]
-
Coises’ proposal should work.
If his solution isn’t quite what you’re looking for, I would probably start by amending the Find what to
POST\s*\[\s*([^\s\]'"]+)\s*\]
and leave the Replace with as is.
Mine is a bit more resilient to corner cases and convertsPOST [ foo ] POST[bar] POST [ baz_quz ] POST [$f89 ] POST["bar"] POST [ "foo" ] POST[ 'bar' ]
to
POST["foo"] POST["bar"] POST["baz_quz"] POST["$f89"] POST["bar"] POST [ "foo" ] POST[ 'bar' ]
-
This post is deleted! -
@Coises
This worked perfect. After I posted, I was doing similar steps, but turns out I put the () in the wrong place and wasn’t getting the right result. Appreciate your help.