A
A
Andrey Dontsov2018-03-18 13:37:01
Regular Expressions
Andrey Dontsov, 2018-03-18 13:37:01

How to make a regular expression for two strings?

There are two lines with a break:

Первая строка<br>
вторая строка

Help with php regex so that the first group includes the first line with the tag
, and the second group - everything after
. Also, special thanks if someone explains my mistake.
I try like this:
$input_line = "Первая строка<br>вторая строка";
preg_match("/(^.*<br>$)(.*)/m", $input_line, $output_array);

in $output_array it turns out this
array(3
 0	=>	Первая строка<br>
 1	=>	Первая строка<br>
 2	=>	
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dontsov, 2018-03-18
@AndreyBLG

Looks like this solution:

reg_grep("/(^.*$)/m", explode("\n", $input_lines));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question