简体   繁体   中英

Find a text substring between two strings (RegExp)

There is a string of text

asd2qw d2er234 568678234111

How to apply d2*234 through RegExp to get “d2er234” and not “d2qwd2er234” ?

This d2.+?234 produces d2qwd2er234

How to limit the last occurrence of d2? Something like (d2)(not(d2)).+?234

Use a tempered greedy token :

d2(?:(?!d2).)*?234

Demo & explanation

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