Re: Moving forward with ISSUE-30 (IRI template expansion)

> A *simple* regex should be enough for parsing.

At the moment, such a regex would look like this:

/^"(.*)"(?:\^\^(.+)|@(.+))?$/

The first group captures the literal value,
the second group the type, the third group the language.
A non-match means the entity is a literal.

var literalRegex = /^"(.*)"(?:\^\^(.+)|@(.+))?$/
literalRegex.exec('http//example.org'); // null
literalRegex.exec('""'); // ['""', '', undefined, undefined]
literalRegex.exec('"abc"'); // ['"abc"', 'abc', undefined, undefined]
literalRegex.exec('"abc"@en'); // ['"abc"@en', 'abc', undefined, 'en']
literalRegex.exec('"abc"^^http://example.org/#type'); // ['"abc"^^http://example.org/#type', 'abc', 'http://example.org/#type', undefined]

Best,

Ruben

Received on Monday, 11 August 2014 20:38:33 UTC