The XML field is as such :
<Element> 0 (0)</Element>
As far as I know this should do what I wish, you can ignore the irrelevant part (e.Descendants) as this is correct (and I have verified this) in the greater scheme of my query. :
Regex regularExpression = new Regex(@"(\d+) \((\d+)\)", RegexOptions.IgnorePatternWhitespace);
And the Linq to XML in question :
variableName = e.Descendants().Where(i => regularExpression.IsMatch(i.Value.ToString())).Select(j => regularExpression.Match(j.Value.ToString()).Groups[1].Value.ToString()).ToList()
However when I attempt to print this value, it is not printing anything.
What have I done incorrectly here ?
您的正则表达式应使用'\\s'
而不是' '
:
Regex regEx2 = new Regex(@"(\d+)\s\((\d+)\)", RegexOptions.IgnorePatternWhitespace);
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.