简体   繁体   中英

Find all certain symbols between two strings

I need to replace all symbols between two strings. For example, symbol is < , strings are <code> and </code> . Text example:

text <code>template<typename T>...<T></code>

I tried next regex:

(<code>[^<]*)<([^\/])

But it finds only first < symbol between <code> (there may be several of them). How can i find all symbols?

You must include the closing </code> in the regular expression to make this work:

/<code>(.*)<\/code>/g

You can play around with it here:
https://regex101.com/r/nHwAHr/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