Azhar Rahi

Azhar Rahi

  • NA
  • 191
  • 0

Get a substring from a qutoed string using C# regex

Apr 28 2020 7:16 AM
Hi
I have a string "\"David\"". I want to read David using C# Regex. What I have done is here:

  1. string strNamePattern = @"^[a-zA-Z][a-zA-Z0-9\ '-]*$";  
  2. Regex re = new Regex(strNamePattern);  
  3. Match match = re.Match(strLastName); 

but match.Success does not return true, so I could not get match.Value. I want that if Lastname contains any single or double quotes at starting and ending position, then it must read the substring within that double or single quote

Answers (5)