I am searching a huge html document on the web that will have multiple instances of names. Each section throughout the page source will contain something like this
{"keyword_text":"kathy smith","item_logging_id":"2021-05-16:yakMrD","item_logging_info":"{"source":"entity_bootstrap_connected_user_suggestion",{"keyword_text":"courtney lee","item_logging_id":"2021-05-16:lX1LC2","item_logging_info":"{"source":"entity_bootstrap_connected_user_suggestion",
I want to grab all the names in the source and put them into a text box.
Search the string for "keyword_text":" then grab all text after until it reaches " excluding the "
I want the end result to be
kathy smith
courtney lee
Considering the "until it reaches the character" you can use the regex ([^\"]*)
^
means NOT and *
means multiple times. So it reads everything until the first appearance of "
. The \
is to escape the quotes.
So in your case this is the regex: \"keyword_text\":\"([^\"]*)
to get the name-part without quotes.
And in c# context:
var matches= new Regex("\"keyword_text\":\"([^\"]*)").Matches(yourInputText);
foreach (Match match in matches)
{
Console.WriteLine(match.Groups[1].Value);
}
string str = "Would \"you\" like to have responses to your \"questions\" sent to you via email?";
var reg = new Regex("\".*?\"");
var matches = reg.Matches(str);
foreach (var item in matches)
{
MessageBox.Show(item.ToString());
}
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.