문제

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.

도움이 되었습니까?

해결책

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

^VT-[A-Z]{3}$
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top