2

I am trying to write a regex format to check the following type string:

40/4

The following features I need:

  • the string will be exactly four characters long
  • 1st character will have to be 1-9
  • 2nd character will have to be 0-9
  • 3rd character will have to be a forward slash (/)
  • and 4th character will have to be 0-9

Here's what I ended up writing:

"/^.{4}$[1-9][0-9][\/][1-9]/"

Please help me to write the correct format.

Thanks

0

1 Answer 1

3

It will be like below:

/^[1-9][0-9]\/[0-9]$/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.