php - Regex txt file with the line breaks and two different delimiters -


this question has answer here:

 --- 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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -