I am creating an droplet to clean up some XML files that I will be exporting from FMP. I started by working with some find and replace commands in TextWrangler. I am now getting them into an AppleScript to have these actions automated. The problematic grep string works in the TextWrangler find window. However AppleScript editor will not allow me to compile with the same said grep string. I have tried to escape some chars that I thought might be the problem, to no avail.
The grep string I am trying to utilize is…
(?<=BarCode>)[\S\s]*?(?=</BarCode)
Any ideas as to where I am going wrong?
You can see my progress below. The line that wont compile is commented out.
on open theDroppedStuff
set TextWranglerAppPath to path to application "TextWrangler"
tell application "Finder" to open file theDroppedStuff using TextWranglerAppPath
--Set reference to docuement that has been opened
set myDocument to (name of document 1 of application "TextWrangler") as string
--open textwranger - clean xml to human readable
tell document myDocument of application "TextWrangler"
--bring all nodes to new line
replace "<" using "\\r<" searching in text 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
--bring all closing tags up a line
replace "\\r</" using "</" searching in text 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
--bring nested "DATA" nodes up a line
replace "\\r<DATA>" using "<DATA>" searching in text 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
--Can't compile - Syntax error - unknown token
--remove specific node's content
--replace "(?<=BarCode\>)[\S\s]*?(?=\<\/BarCode)" using "This is a test" searching in text 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
end tell
end open
on run
-- this handles a double-clicked icon
display dialog "Use this script to clean an FMP XML file. Drop the XML file on this applicaion icon."
end run
Model: iMac
AppleScript: 2.2.2
Browser: Safari 536.25
Operating System: Mac OS X (10.8)