Reputation: 37
I have string like :
<plaintext>10/2 (2×5 + (10 - 1)×2)</plaintext>
</subpod>
<expressiontypes count='1'>
<expressiontype name='Default' />
</expressiontypes>
</pod>
<pod title='Exact result'
scanner='Rational'
id='Result'
position='200'
error='false'
numsubpods='2'
primary='true'>
<subpod title=''>
<plaintext>140</plaintext>
</subpod>
<plaintext>Simplify the following:
(10 (2×5 + (10 - 1) 2))/2
(10 (2×5 + (10 - 1) 2))/2 = (10 (2×5 + (10 - 1) 2))/2:
(10 (2×5 + (10 - 1) 2))/2
10/2 = (2×5)/2 = 5:
5 (2×5 + (10 - 1) 2)
10 - 1 = 9:
5 (2×5 + 9×2)
2×5 = 10:
5 (10 + 9×2)
9×2 = 18:
5 (18 + 10)
| 1 | 8
+ | 1 | 0
| 2 | 8:
5×28
5×28 = 140:
Answer: |
| 140</plaintext>
And i want to get string between these two tags <plaintext>
, </plaintext>
My code so far
StringBuilder stringBuilder = new StringBuilder();
Regex regex = new Regex(@"<plaintext>(.*?)</plaintext>");
foreach (Match match in regex.Matches(here is string above)
stringBuilder.Append(match.Groups[1].Value);
But my regex get only string in same line but when <plaintext>
, </plaintext>
tags are on different lines - cant parse it.
Upvotes: 0
Views: 61
Reputation: 6173
You need to add RegexOptions.Singleline
to your regex-arguments like this.
var regex = new Regex(@"<plaintext>(.*?)</plaintext>",
RegexOptions.IgnoreCase | RegexOptions.Singleline);
Then it will capture everything except newlines.
Upvotes: 1