php - Regex txt file with the line breaks and two different delimiters -
this question has answer here:
- my regex matching much. how make stop? 4 answers
--- settings --- first: 1 second: 2 --- settings 2 --- first: 3 second: 4 --- settings 3 --- first: 5 second: 6
i trying parse regex
#--- ([a-za-z0-9-_,. ]+) ---\n(.*)\n#is
but getting block --- settings --- second: 6.
how can parse correctly?
with s
modifier, .*
grab can, including newlines , else.
try adding ?
after .*
make regex not greedy. i.e.
#--- ([a-za-z0-9-_,. ]+) ---\n(.*?)\n#is
or drop s
modifier if don't need - .*
stop @ end of line.
Comments
Post a Comment