Reputation: 226
Struggling with this one.... This is my data, I want to select all from the first data-group until the next
Original
data-group object name
1234
5677
7890
12356
data-group object name2
Desired Output
data-group object name
1234
5677
7890
12356
I'm currently looking into positive look ahead, and have come up with the following expression
(?=data-group)data-group
This selects.
data-group
data-group
How do I get it to match anything between on the new line.
Upvotes: 2
Views: 1133
Reputation: 174696
You need to use DOTAll
modifier (?s)
inorder to make dot to match line breaks.
(?s)\bdata-group\b.*?(?=\bdata-group\b)
OR
This won't print an extra newline character at the last.
(?s)\bdata-group\b.*?(?=\ndata-group\b)
Use [\s\S]*?
instead of .*?
if your lang won't support s modifier. [\s\S]*?
matches any space or non-space character zero or more times non-greedily.
\bdata-group\b[\s\S]*?(?=\ndata-group\b)
Upvotes: 1