简体   繁体   中英

C# Regex between html tags

Heres the original input: <div class="title">Name Name<br/>Score: 24375</div>

Heres my regex: @"<div.*?class=""title"".*?>(?<div>).*</div>"

This is what I got from the site: <div class="title">Name Name<br/>Score: 975</div>

I would like to get the Name Name from the tags.

Use a lookbehind to match the content of <div> tag until a < or > symbol is reached.

(?<=<div\s*class=""title""[^><]*>\s*)[^<>]*

IDEONE

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