Hi, I would like to select everything between the word “start” and “end”.
Like this in Regex: (?<=start)(?s)(.*)(?=end)
Problem:
If the word “end” is not there it should still select everything after start.
Hi, I would like to select everything between the word “start” and “end”.
Like this in Regex: (?<=start)(?s)(.*)(?=end)
Problem:
If the word “end” is not there it should still select everything after start.
I tried, but no luck.
As an alternative, you can have two regex expression based on end is there in the string or not.
If string.Contains("end")
(?<=start)(?s)(.*)(?=end)
else
(?<=start)(?s)(.*)
End If
Can you try the below pattern. Same logic as Karthik suggested
((?<=start)(?s)(.*)(?=end))|((?<=start)(?s)(.*))
This works for both single line and multi line
((?<=start)(?s)(.?(?=end)|.))
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.