Wednesday 29 November 2017

sublimetext2 - Oniguruma Regex - Match entire group content and not just the last occurrence

I'm writing a syntax highlighter for the Sublime Text
editor (that uses the Oniguruma regex definitions). Basically, I have something like
this:




Regex:
\((\w+\s*)*\)



Test:
(how
are you)



Capturing
groups:
1.
you



My problem is, that only the
last occurrence in the capturing group is matched (and therefore highlighted) and not
the entire content of the capturing
group.




In my concrete
case:



Regex:
\(\w+(\s+(\?\w+\s+)+-\s+(\w+))*\)



Test:
(at
?l - location ?x -
object)



Capturing
groups:




1. ?x -
object
2. ?x
3.
object


However, I'd
like to match the entire group content, like
that:



1. ?x - object AND ?l -
location
2. ?x AND ?l

3. object AND
location

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...