Regex to first occurrence only?
regex
Solution
The regex is greedy meaning it will capture as many characters as it can which fall into the `.*` match. To make it non-greedy try:
`this(.*?)test`
The `?` modifier will make it capture as few characters as possible in the match.
Problem
Let's say I have the following string: this is a test for the sake of testing. this is only a test. The end. and I want to select `this is a test` and `this is only a test`. What in the world do I need to do? The following Regex I tried yields a goofy result: `this(.*)test` (I also wanted to capture what was between it) returns `this is a test for the sake of testing. this is only a test` It seems like this is probably something easy I'm forgetting.