In Typescript, how to validate string pattern? example const str = "ABC1-AB9"
- max length should be 8
- string pattern should be xxxx-xxx
- x can be A-Z and 0-9 only
In Typescript, how to validate string pattern? example const str = "ABC1-AB9"
^[A-z0-9]{4}-[A-z0-9]{3} [0-9]{1}
This could be the regex you are looking for. You can test the same by going to https://regexr.com/ website and making your own custom regex.