Using regular expressions

I’m working on a translation tool for Duik 15 (it is the last thing I have to develop to finish it); instead of including the translations inside Duik, I decided to develop a framework to translate any Adobe ExtendScript.

I’ll talk about this framework later, for now, what I needed was a simple yet reliable tool to extract all strings from the script to translate. Which leads me to what I want to share now:

  • A wonderful site to write and test (and share) your regular expressions : Regexr (v2)

    If you develop some scripts and tools but don’t know what a regular expression is, I think you should look at it! It’s a very powerful and versatile tool (search, replacement, validation…)

  • Here is a useful regular expression which matches any string surrounded by double quotes in Javascript (therefore in Adobe ExtendScript too), including strings containing escaped quotes (\").

    Here it is:
    \"([^\"\\]*(?:\\.[^\"\\]*)*?)\"
    Quick explanation:
    \" : find the first double quote
    [^\"\\]* : All characters coming next which are not a backslash nor a double quote.
    (?:\\.[^\"\\]*) : a block to get backslashes and the character coming next ( \\. ), then once again any character coming next which are not a backslash nor a double quote ( [^\"\\]* )
    * : at last, this block is repeated until a final double quote is found ( \" )


I could not do and share what I do for free without your support. Help me on Patreon! Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.