3
3
3098482020-03-01 15:26:34
PHP
309848, 2020-03-01 15:26:34

PHP preg_match - how to pull an entry?

Good afternoon!

Help plz with regex - how to get only the first occurrence between 21 and 91? Now "xxxx91xxxx" is returned.

$string = '01xxxx21xxxx91xxxx91xxxx';

preg_match(('/^01(.*)21(.*)91.*$/'), $string, $re);

array(3) { 
[0]=> string(29) "01xxxxx21xxxxxx91xxxxx91xxxxx"
[1]=> string(5) "xxxxx" 
[2]=> string(13) "xxxxxx91xxxxx" }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-03-01
@309848

/(?<=21).*?(?=91)/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question