tell application "BBEdit"
tell front text window
replace "(/\\*[^\\*]*\\*/)" using "<!--\\1-->" options ¬
{search mode:grep, case sensitive:false, starting at top:true}
replace "(/\\*|\\*/)" using "" options {search mode:grep, case sensitive:false, starting at top:true}
replace "%@" using "%1$s" options {case sensitive:false, starting at top:true}
end tell
end tell
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/B4B02A99-8F77-4877-93AD-328302B74BBB%40cruzio.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/51834A85-668C-4A18-903C-3DCA88FD83A3%40cruzio.com.
Yes, double escapes are needed. As handy as Applescript is, quoting is a major pain point.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/3199598c-4f6c-4d5e-8ca2-03d81dea5b6fn%40googlegroups.com.
tell application "BBEdit"
tell front text window
replace "(\"[^\"]+?\") = \"([^\"]+?)\";" using "<string name=\\1>\\2</string>" options ¬
{search mode:grep, case sensitive:false, starting at top:true} -- RegEx replacement.
replace "/\\*([^*]*?)\\*/" using "<!--\\1-->" options ¬
{search mode:grep, case sensitive:false, starting at top:true}
replace "%@" using "%1$s" options {case sensitive:false, starting at top:true} -- Literal replacement.
end tell
end tell
OK, but I have one outstanding issue.
What I would like is take *everything* between the last to quote signs as the body of the xml node. However, it doesn't work with escaped characters.
As an example, if I take the above row and change it to
"login_welcome" = "Welcome to \"My App\" "; - it doesn't work.
What I would like is basically "between quote one and two, use in <string name="">, then everything between quote number three and the ending ' "; ' use as body, then end with </string>.
Does this name sense?
OK folks, I feel like I'm nearly there, but I have a small outstanding issue that perhaps you can find it in your heart to help me with.