0

I need to specify that my user name has to start with one of two words, followed by a backslash. It can only accept the words cat or dog at the beggining and then a backslash is expected, for example:

  cat\something
  dog\something

Both are accepted. What's the regular expression for this? I've tried some regular expressions but I haven«t figured it out yet.

Sam
  • 247
  • 5
  • 16

1 Answers1

0

The solution is:

^cat\\.*|^dog\\.*

https://regex101.com/ is a great tool for testing and evaluating regular expressions.

Grigory Zhadko
  • 1,484
  • 1
  • 19
  • 33
metmo
  • 16
  • 2