Sublime Forum

Sublime-syntax regex find squared brackets

#1

I am doing my own sublime-syntax file. Basically it’s an text based file, so scope is text.test
scope: text.test
I want to have a find with “goto definition”

“any text here and find findthis and so on”

[Name] findthis

it works without squared brackets like

Name findthis

  • match: Name\s*(\w.*)
    scope: meta.function.text.plain
    captures:
    1: entity.name.function.text.plain

but my goal is to make it with sqaured brackets

The definition of findthis should be that
[Name] findthis

I have googled and tried many differnt soltuions. None of them did work

  • match: [Name]\s*(\w.*)
  • match: \[Name\]\s*(\w.*)
  • match: [Name]\s*(\w.*) // I was reading, closed bracket doesn’t need a \ if there is no open bracket
  • match: ([)Name(])\s*(\w.*)
  • match: (\[)Name(\])\s*(\w.*)
  • match: ("\[")Name("\]")\s*(\w.*)
    and maybe a few more … no success …
0 Likes

#2

have you tried quoting the regex?

- match: '\[Name\]\s*(\w.*)'
  scope: meta.function.text.plain
  captures:
    1: entity.name.function.text.plain
0 Likes

#3

Yes, I have tried that also. Thanks for your support.
Unfortunately it does not help. Any further ideas are very welcome.

0 Likes

#4

Solved :blush:
One night sleeping helps sometimes :relaxed:

It does work “now”

  • match: \[Name\]\s*(\w.*)
    scope: meta.function.text.plain
    captures:
    1: entity.name.function.text.plain

My problem was, that before I have defined

  • match: \[
    scope: punctuation.section.group.begin.romd

  • match: \]
    scope: punctuation.section.group.end.romd

Which obviously did not match with \[Name\] afterwards.
I have moved it before the matches of \[ and \] … tata … it works
Mabye that awareness helps one day someone.
Thank you kingkeith for supporting me.

PS: I see just know that in my first entry, the \ are missing, because in that forum you have to do double \\ to see one \.

0 Likes