Hi there, I'm new here and just learning Regular Expressions and am looking for some help on the following problem.
I want to replace <p> tags with <li> tags in a large HTML string using a regular expression.
I would like the following input to translate to the following output:
Input:
<p>test</p>
<p class="a">test</p>
<p class="a">test</p>
<p>test</p>
Output:
<p>test</p>
<li>test</li>
<li>test</li>
<p>test</p>
So Far I have as follows:
RegEx: <p class="a">(?'S1'.*)</p>
Replace: <li>${S1}</li>
The problem occurs when the Input is on the same line:
Input:
<p>test</p>
<p class="a">test</p><p class="a">test</p>
<p>test</p>
Output:
<p>test</p>
<li>test</p><p class="a">test</p>
<p>test</li>
I understand that the regex is finding the first instance of <p class="a"> and taking everything in between and finding the last </p>, however, as you can see it is not my desired result.
Is there an indicator that will allow me to specify "find the following </p> after finding the <p class="a"> and apply the regex to that"
I am using C# with the following basic code for testing purposes.
Regex.Replace(txtInput.Text, txtRegEx.Text, txtRegReplace.Text, RegexOptions.Singleline | RegexOptions.IgnoreCase);
Any help would be appreciated.
harry