Hi people.
I would need a regular expression that escapes or captures (if not already escaped) ALL the double quote characters INSIDE a single quoted string and then convert the opening single quotes to double quotes!
We are refactoring files that have a lot (and i mean a lot!) of single quoted strings in either PHP and also JS files. The only thing they have in common is that the strings are at least in one line and are concated with = in both languages.
I give an example (the example is ugly legacy code so dont judge it please, i already did this :) ) We have a file that starts like this:
var baseUrl = $("#baseurl").html();
var head = '<div id="finishingDiv" style="background-image:url({baseUrl}css/userAd/images/out_main.jpg); background-repeat: repeat-y; ">'+
'<div id="buttonbar" style="width:810px; text-align:right">';
and i want it to look like this:
var baseUrl = $("#baseurl").html();
var head = "<div id=\"finishingDiv\" style=\"background-image:url({baseUrl}css/userAd/images/out_main.jpg); background-repeat: repeat-y; \">" +
"<div id=\"buttonbar\" style=\"width:810px; text-align:right\">";
As you see the correct double quote strings are not touched.
So my basic question: How do i capture all characters of one kind (in my case the character " ) between a certain start and end character (in my case the character ' ).
This regex '.*(").*'
or '[^']*(")[^']*'
just captures always one " for me per match. If if needs more than one step its also ok, it should just work.
I would be happy of any solution, IDE specific, language specific or shell specific, that acutally works.
Please help, im desperate, thanks a lot