LINQ use regex to select fields and substrings from List

I’m trying to parse a list of results from a Dapper query and select title, url, and a substring of the url matching a regex. I can’t seem to get the LINQ query to return the substring or understand how to get the other fields in there as well.

Excerpt:

string query = $@"Select id ,title ,url ,last_visit_date from moz_places where title like '%{titleMatch}%'"; if (urlMatch.Length > 0) query += $" and url like '%{urlMatch}%'"; var results = conn.Query(query).ToList(); var data=results .Select(r => Regex.Match(r.url,@"reddit.com/r/(.*?)/")); 

submitted by /u/JeffIpsaLoquitor
[link] [comments]

Leave a Reply