I validate the string, but for some reason it does not accept the firebase.

More on the screenshots:

screenshot from firebase

On the validator, everything is fine with validator

I don’t understand what’s wrong here

  • one
    Double all \ . - Wiktor Stribiżew
  • Post text, not pictures. - Wiktor Stribiżew
  • I did not read the answer carefully. Doubled everything \, now everything works. Thanks a lot - ivan0biwan
  • Share the link to regex101 to write the answer faster. - Wiktor Stribiżew
  • Here is the link regex101.com/r/ybc9LV/1 - ivan0biwan

1 answer 1

In Firebase, the regular expression is passed as a string literal, so all backslashes need to be escaped. Straight slashes must be escaped, as these characters are used to "delimit" a regular expression ("regex delimiters").

Use

 .matches(/^steam:\\/\\/joinlobby\\/[0-9]{2,5}\\/[0-9]{10,20}\\/[0-9]{10,20}$/) ^^ ^^ ^^ ^^ ^^