regex - How can I extract a certain number from a string using Regular expresions? -


i think easy don't have time learn how it.

in html file, have class of paragraph, let´s say:

<p class="footnote"></p> 

the "p" tag followed numbers, increase 1 in every instance. let's first number "43". want series of numbers start 1, need substract 42 paragraphs.

for example, want go from:

<p class="footnote">43. lorem</p> <p class="footnote">44. ipsum</p>.  <p class="footnote">45. dolor</p>.  

to

<p class="footnote">1. lorem</p> <p class="footnote">2. ipsum</p>.  <p class="footnote">3. dolor</p>.  

¿how can it?

if you're looking regex that'll handle <p class="footnote">43. lorem</p> answer don't parse html regex.

assuming you've extracted string 43. lorem tag , want number out depends on requirements:

to find number: \d+

to find number @ beginning: ^\d+

to find number followed period: \d+\.

a more complete solution require more details problem including programming language want use.


Comments