Satimage Previous
Debugging a Regular expression
Home Documentation Smile Text commands Debugging a Regular expression  
Suppose you want to use find text or change with a Regular expression in a script. Here is how we recommend that you debug it.
  • Open a new Unicode window
  • In the new window, copy some text, representative of what the Regular expression in your script will work on. This will be your test text.
  • Open the Find dialog. Enable the Regexp check box.
  • Build your Regular expression in the search string field. Use the metacharacters list provided in the pop-up menu close to the Regexp check box. We advise to build the Regular expression progressively, checking with the Find button that it behaves like you expect. If a long Regular expression does not find a string that it should find, try testing only a sub-pattern.
  • If you want to test change, you can test the replace string with the Replace button.
  • Once your Regular expression works and is tested, copy the content of the text field(s) of the Find dialog into your script. Do not add the double-quotes manually. Instead, select the Regular expression in your script then press ⌘" (or select the menu command User Scripts ▸ More Smile commands ▸ Scripting ▸ Make an AppleScript string ⌘"). This will add the double-quotes and will escape the characters which require so.
Copyright ©2008 Paris, Satimage