Regex Match expression using double quotes

Hello,
I want to extract the text between two sustrings. The first of them is ’ title="" ’ and the second one is " “” ". For example:

String is “<span title =”“Target text to be extracted”" custom_id-"“5"”>SomeOtherText"

The ouput should be: Target text to be extracted.

Observation: Note the twice double quote usage outside the target string. Can anyone help please?

@Bruno_Aarao Can you Check if this regex works for all the input types that you have ?

The two double quotes are a way to indicate that the double-quote is actually part of the string, not a delimiter.

You set your pattern accordingly.

Text = "<span title =""Target text to be extracted"" custom_id-""5"">SomeOtherText"
Pattern = "title\s?\=\s?""(?<title>.+?)"""
Title = System.Text.RegularExpressions.Regex.Match(Text, Pattern).Groups("title").ToString
1 Like