A
A
Alexey Tolstoukhov2018-03-25 07:05:19
Regular Expressions
Alexey Tolstoukhov, 2018-03-25 07:05:19

Case insensitive in preg_match_all?

Hello.
Interested in such a question, there is a base of the form:
$base = "Hi:hi".
"testik:Toaster".
"hi:HI"; // base just as an example
$text = "hello";
It is necessary that through preg_match_all('@\b'.$text.'\:(.*)@', $base, $answer);
Printed both values ​​case insensitively.
If you try now, then the case is taken into account and will display "HIGH".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-03-25
@kaktys123

preg_match_all('/\b'.$text.'\:(.*)/i', $base, $otvet);

Try something like this .. I haven’t worked with regular expressions for a long time .. I don’t know why I wrote it correctly .. But as I understand it, the regular season is beaten off with the @ symbol, but usually they beat off / slash (or is it a backslash, otherwise the smart people will fly in ..) flags i can be passed at the end of the regular expression, this makes it case insensitive.
archive-ipq-co.narod.ru/l1/regexp.html
on-line-teaching.com/php/regexp.htm
Here are two articles I like. I don't think it's hard to figure them out.

D
Dmitry Entelis, 2018-03-25
@DmitriyEntelis

Convenient tool for checking https://regex101.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question