To extract the text between the pattern >>Digit<<
, I have successfully used regex "(?<=\>>[0-9]+?<<)[ ].+?(?=\>>[0-9]+?<<)
". Regex option is set to single line because the to-be-extracted text may be multiline.
>>1<< First Option For Third Variable Reply1 >>1<<
>>2<< Second Option For Third Variable Reply 1 >>2<<
>>3<< Third Option For Third Variable Reply 1
>>3<<
If I remove the [ ]
portion of the regex "(?<=\>>[0-9]+?<<).+?(?=\>>[0-9]+?<<)
", matches using the regex will actually extract white spaces (e.g. between >>1<<
and >>2<
) which is not my intent. I don't understand why adding [ ] excludes those white spaces.
I understand that square brackets in regex generally signify character classes that are to be included. But here, by inserting square brackets with a space, I manage to exclude the white spaces (e.g. between >>1<<
and >>2<
). So I am trying to understand how it worked in my case.
Thank you.