Example:
This is just\na simple sentence.
I want to match every character between This is and sentence. Line breaks should be ignored. I can’t figure out the correct syntax.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For example
Regexr
I used lookbehind
(?<=)and look ahead(?=)so that “This is” and “sentence” is not included in the match, but this is up to your use case, you can also simply writeThis is(.*)sentence.The important thing here is that you activate the “dotall” mode of your regex engine, so that the
.is matching the newline. But how you do this depends on your regex engine.The next thing is if you use
.*or.*?. The first one is greedy and will match till the last “sentence” in your string, the second one is lazy and will match till the next “sentence” in your string.Update
Regexr
Where the (?s) turns on the dotall modifier, making the
.matching the newline characters.Update 2:
is matching your example “This is (a simple) sentence”. See here on Regexr