简体   繁体   中英

PHP Regex pattern for C???-??-?-*

I need to match a string to this pattern C???-??-?-* (example: CRPN-NN-N-036+ )

So far I found this regex pattern:

/^(C-)*[a-zA-Z]{3}-[a-zA-Z]{2}-[a-zA-Z]-

But this doesn't work.

^C[a-zA-Z]{3}-[a-zA-Z]{2}-[a-zA-Z]-.*

这是一个例子

The dot (.) matches a single character, without caring what that character is. The only exception are line break characters.

So, we can use ^C.{3}-.{2}-.-.* to make the regex more general. This pattern even can match C???-??-?-*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM