Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Latest commit

 

History

History
28 lines (24 loc) · 813 Bytes

string.md

File metadata and controls

28 lines (24 loc) · 813 Bytes

Example: <string>

The following example parses strings indicated by double-quotes. Usage of the double-quote in the string itself is possible by escaping it

entry {
    default [object:
        '"'
        
        # Match all characters except the quotation character.
        # Match escaped quotation-characters first.
        def string = [['\\"' | (. except \")]+]
        '"'
    ]
}
Valid inputs:
Input Output
parse('"Hello World"') {string: 'Hello World'}
parse('"Say hello with \"Hello World\" !"') {string: 'Say hello with \'Hello World\' !'}
Invalid inputs:
Input Output
parse('"Ooops') null (Missing closing quotation-sign)
parse('"Hello " World"') null (Quotation not escaped)