Sublime Forum

Multiline regex for tmLanguage

#1

I have to maintain some legacy Oracle PL/SQL code. I prepared my personal plSQL.tmLanguage to detect constructs like “create or replace package abc.xyz is”. I have a regex which highlights the keywords and the identifier .

Unfortunately some of the legacy code has “random” newlines between the words, e.g.
“create or replace
package abc.xyz is”
My attempt was to insert an optional “\n*” in my regex as shown below.

\b(create\s+(or\s+replace\s+)?\n*\s*package\s+(body\s+)?)(([a-z][a-z0-9_#\$]*\.)?([a-z][a-z0-9_#\$]*))\b

This will work with “The Regex Coach” I use to verify my regexes.
This does not work with sublime. :cry:

Is there any chance to get a regex to span multiple lines?

0 Likes

#2

As far as I know, syntax regexes not consuming the newline char is a design choice in TextMate for efficiency.

If you need to style multiple lines, I believe your only option would be to define a begin…end rule.

0 Likes

#3

Hmm, the regex above is the begin of a begin…end rule.

It will be very tedious to integrate possible newlines in rules as they can occure where whitespace is possible.

0 Likes