Pattern: Quoted string

“Quoted string” is one of the patterns that you can select on the Match panel. With this pattern you can match a quoted string as it would appear in the source code in one of many popular programming languages.

  1. Click the New Formula button on the top toolbar to clear out all settings on the Samples, Match, and Action panels.
  2. On the Samples panel, paste in one new sample with some sample code:
    quote = "It's a beautiful day!"
    message = '''This is a string
    that spans multiple
    lines.'''
    escapes = 'This is a line.\nAnother line with \'quoted\' text.\n'
  3. On the Match panel, set both “begin regex match at” and “end regex match at” to “anywhere”.
  4. Click the Add First Field button to add field 1.
  5. In the “pattern to match field” drop-down list, select “quoted string”.



  6. In the “string style” drop-down list, select Python.
  7. On the Regex panel, select “Python 3.13” as your application, turn off free-spacing, and turn off mode modifiers. Click the Generate button, and you’ll get this regular expression:
    """(?:[^"\\]++|\\(?s:.)|"{1,2}+(?!"))*+"""|'''(?:[^'\\]++|\\(?s:.)|'{1,2}+(?!'))*+'''|"[^"\\\r\n]*+(?:\\.[^"\\\r\n]*+)*+"|'[^'\\\r\n]*+(?:\\.[^'\\\r\n]*+)*+'
    Unused options: Case sensitive; Exact spacing; Dot doesn’t match line breaks; ^$ don’t match at line breaks.
  8. The Samples panel now highlights the quoted strings in our sample code:
    quote = "It's a beautiful day!"
    message = '''This is a string
    that spans multiple
    lines.'''
    escapes = 'This is a line.\nAnother line with \'quoted\' text.\n'

The programming language you select for your string style is completely independent of the target application or language that you generate your regular expression for. If you want the same regular expression to handle multiple string styles then you can use an alternation field to match one of several fields that use the “quoted string” pattern with different programming languages.

Reference