I want a regex that will return zero or more occurrences of matched substrings of different patterns.
Different patterns to match
<sym>Any value</sym>
<sps>Any value</sps>
<sbs>Any value</sbs>
Any string including spaces and special characters which are outside of the above 3 tags
Where "Any value" is any string including spaces and special characters.
Test Cases
abcd<sps>2</sps><sbs>yy</sbs>efgh<sym>b</sym>
<sym>nu</sym>Hello World<sps>6&</sps><sbs>10</sbs>With Special Characters$#<sym>b</sym>
<sps>2</sps>Test<sbs>yy</sbs><sym>b</sym>End String
Results
1.
abcd <sps>2</sps> <sbs>yy</sbs> efgh <sym>b</sym>
<sym>nu</sym> Hello World <sps>6&</sps> <sbs>10</sbs> With Special Characters$# <sym>b</sym>
<sps>2</sps> Test <sbs>yy</sbs> <sym>b</sym> End String
I tried the following regex:
(?([a-zA-Z0-9]+))<sym>[^.]*</sym>|<sps>[^.]*</sps>|<sbs>[^.]*</sbs>(?([a-zA-Z0-9]+))
Result against "Test Case 1": Getting the following strings where I am not getting the strings outside the tags.
<sps>2</sps> <sbs>yy</sbs> <sym>b</sym>
Result against "Test Case 2": Getting the full input text.
<sym>nu</sym>Hello World<sps>6&</sps><sbs>10</sbs>With Special Characters$#<sym>b</sym>
Could you please help me in this context. Thank you in advanced!