If I have a string as follows
XXXasdf23s5\r\n
asdflkoirfn329i 4\r\n
sef29384ewrj280 39\r\n
XXX123sd3t334\r \n
sdorfu23984rr\r \n
sdflk2893rjf\r\ n
weirj2983jhwer2 398\r\n
XXX12356789\r\n
4w3ujr523q938er \r\n
basically I am searching for sections that begin with XXX but I don't know what the end will be. All I know is that the next section will definitely start with 'XXX'
Can I search for ^XXX.*\r\n(.*\r \n)*XXX
but add something to the regular expression to backtrack to before the next XXX that I matched and ignore it? I want my match to exclude it.
(I tried (?=XXX) but I could not get it to work)
Thanks for any advice
XXXasdf23s5\r\n
asdflkoirfn329i 4\r\n
sef29384ewrj280 39\r\n
XXX123sd3t334\r \n
sdorfu23984rr\r \n
sdflk2893rjf\r\ n
weirj2983jhwer2 398\r\n
XXX12356789\r\n
4w3ujr523q938er \r\n
basically I am searching for sections that begin with XXX but I don't know what the end will be. All I know is that the next section will definitely start with 'XXX'
Can I search for ^XXX.*\r\n(.*\r \n)*XXX
but add something to the regular expression to backtrack to before the next XXX that I matched and ignore it? I want my match to exclude it.
(I tried (?=XXX) but I could not get it to work)
Code:
System.Text.RegularExpressions.Regex xxxRegex = new System.Text.RegularExpressions.Regex(@"^XXX\|.*\r\n(.*\r\n)+(?=XXX)", System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.Compiled);
Comment