-1

I need to verify this pattern:

{{ a valid variable name }}

Something like this:

/{{aaaa}}     ---> matches
/{{a}}        ---> matches
/{{a1a}}      ---> matches
/             ---> matches
/{aaa}}       ---> no matches
/{aaa}        ---> no matches
/{{aaa}       ---> no matches
/aaa}}        ---> no matches
/{{aaa        ---> no matches

and so forth...

I have this pattern:

^\\/(({){2}[A-Za-z0-9]+(}){2})*$

According to https://www.debuggex.com/#cheatsheet it is well written, but it doesn't work. Any suggestion on how to solve this?

3
  • What does it mean by "it doesn't work"? Which tests does it fail? Commented Apr 13, 2020 at 14:45
  • ^\{{2}[\w]+\}{2}$ can you please try this Commented Apr 13, 2020 at 14:47
  • It is not a good practice to downvote without saying why. Also, this question has nothing to do with the suggested stackoverflow.com/questions/4674237/…, completely different questions. Commented Apr 14, 2020 at 13:08

1 Answer 1

1

At the start, you need to escape the / correctly:

^\/(({){2}[A-Za-z0-9]+(}){2})*$
 ^

Also, this can be simplified by removing the {2}:

^\/(({{)[A-Za-z0-9]+(}}))*$
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.