Question

I need a regular expression to validate the text in a particular format Eg: VT-ABC

This particular regular expression should start with VT- followed by 3 alphabet letters. The whole string should contain exactly 6 characters.

I tried the regular expression ^[V][T][-][A-Z]{6}, but this is not working.

Any guidance would be appreciated.

Was it helpful?

Solution

You need an end-of-string anchor, and of course only three letters should be allowed, not six:

^VT-[A-Z]{3}$
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top