Reputation: 13
I have had some problems using preg_match, Instead of selecting 1 thing. It finds from the start of the first, to the end of the last.
preg_match('/@section\(\'(.*)\'\)(.*)@endsection/s', $content,$results
$Content :
@section('title')
Number 1
@endsection
@section('content')
Number 2
@endsection
But when i use the preg_match, the result comes out like :
Number 1
@endsection
@section('content')
Number 2
Upvotes: 1
Views: 220
Reputation: 21437
You are looking for non-greedy quantifier over here like as
/@section\(\'(.*?)\'\)(.*?)@endsection/s
//^^ ^^
Upvotes: 2