简体   繁体   中英

How to build an exact matching regex?

I need to parse certain github image tags which are of the form service-pr-07
service-abc1234 service-master-latest

I was using regex /^#{service_name}-/ to find out the relevant data but this fails since the new tags are of the form service-core-pr-99 , service-core-abc345 etc. The old regex will return the service-core results also. What should I use?

Why not just use pattern = r'^service' ? That will match the first three forms you want and the service-core forms too.

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