N
N
NWMCStarik2018-03-14 15:08:57
PHP
NWMCStarik, 2018-03-14 15:08:57

PHP regular expressions?

There are lines: 128 129 129a 12A 12Vk1 12a 12k0str0
You need to get where only numbers or numbers and at the end one letter.
I am not familiar with regular expressions, please help.
Tried to write

if (preg_match("/^[(0-9){0,3}+(а-я{0,1})]+$/", $home["name"]))
. But that's not how it works.
And then I tried "/^\d+|\d+[а-я]?/"skipping all the lines

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-03-14
@NWMCStarik

if (preg_match("/^\d+[а-я]?$/iu", trim($home["name"])))

for unicode in php, you also need to write the u modifier in the regular expression, and the i
modifier so that it is case -insensitive php.net/manual/ru/reference.pcre.pattern.modifiers.php https://regex101.com/r/0yhZvy/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question