E
E
Evgeny Kramor2018-02-16 09:16:20
PHP
Evgeny Kramor, 2018-02-16 09:16:20

How to prevent character input except for some using preg_replace?

There is a lot of material on the Internet about this, but I would like to know specific things for myself. How to prohibit all characters in the $title variable , except for ,.- , and insert - instead of prohibited ones - and so that - does not repeat more than once.
Input data: Cyrillic and Latin.

$title = preg_replace("/[^A-Za-z0-9]/"," ",$title);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2018-02-16
@xmoonlight

You can find out here .
Test: here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question