简体   繁体   中英

python regular expression match a pattern

So, I have been trying to match a simple pattern like B0000001 where just the first character be an alphabet " B " and rest should be numbers. The total length should be 9.

I tried the pattern "^B[0-9]{7}$" but it fails most of the time. Any suggestions?

Use this expresion:

^B\d{8}$

Demo

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