简体   繁体   中英

Regex, match any character after match

I'm trying to match the entire string when I have identified the middle part.

I have the string:

first:second:third:forth:fifth

I wish to match it when I write for example: :third:

I do not wish to match it when I write for example :sixth:

I've figured out the first half, been looking around for the regex to extend to include any character after the match.

在此处输入图片说明

You want a look-ahead check:

(?=.*:third:).*

https://regex101.com/r/48Adar/1

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