I am looking for certain entries with special words in a string. The string looks like this.
entry 1: hello
entry 2: world
entry 3: this
is a multiline
that makes it hard
entry 4: here we have a special entry
entry 5: here
we
have
another special entry
in a multiline
entry 6: end
Because it is an multiline problem I use Java's DOTALL so that the .
matches also newline characters.
I am looking for entries that have the word special in it.
First I tried to find a regex, that captures a full entry: entry \d+: .*?(?=\s*(entry \d: )|\Z)
. That is like a simplified version of this
Then I thought, ok I just have to exchange the .*?
for the regex I need to find. But entry \d+: .*?special.*?(?=\s*(entry \d: )|\Z)
does not work, probably because the special breaks the greed of the expression.
Does anyone know a better solution?