Question:
I have following string:</transactionshares>
” and “<transactionacquireddisposedcode>
” by using:None
, which is wrong.
Expected output:I thought the search string “/” was the cause of this problem, therefore I tried using
<\/transactionshares>(.*)<transactionacquireddisposedcode>
Still I don’t get my expected output. Both of search strings work on regex101.
Thank you for any help.
Answer:
The\n
is messing you up. adding flags=re.DOTALL
will make your .*
include the \n
<\ntransactionPricePerShare>
I also changed the
.*
to a .*?
to make it less greedy, which you may want. That way it stops at the first <transactionacquireddisposedcode>
If you have better answer, please add a comment about this, thank you!