my input is:
<span question_number="18"> blah blah blah 1</span><span question_number="19"> blah blah blah 2</span>
and I want my regex to match this
<span question_number="somenumber">xxxx</span>
pattern
and the desired output is 1.somenumber 2.xxxx
I wrote a naive solution which could cover
<span question_number="18"> blah blah blah 1</span>
<span question_number="19"> blah blah blah 2</span>
notice: they are on different lines
the output is : 18
, blah blah blah 1
and 19
,blah blah blah 2
but when the input is <span question_number="18"> blah blah blah 1</span><span question_number="19"> blah blah blah 2</span>
which is on the same line
my output is 18
, blah blah blah 1</span><span question_number="19"> blah blah blah 2
how could I bypass this problem?
Update:
regex: /\<span question_number=(?:\")*(\d*)(?:\")*>(.*)<\/span>/ig
testinput:
case1 -> two lines of code
<span question_number="54">often graces doorways tied into ropes called</span>
<span question_number="54">often graces doorways tied into ropes called <i>ristras</i>.</span>
case2 -> one line of code
<span question_number="54">often graces doorways tied into ropes called</span><span question_number="54">often graces doorways tied into ropes called <i>ristras</i>.</span>
Update2:
This is not a dom , it is just a plain text that I want to process.
Update3: so my problem about Regex is solved, now I have a question about comparing the proessing speed between regex or dom operation ? how could implement such a test ?