Answer the question
In order to leave comments, you need to log in
How to create input mask (format) for tg bot in php?
Hello! Faced the problem of filtering the data sent to the tg bot. In the bot, you need to fill out a questionnaire, all data is sent to the database .. for example, with the price range field, I decided using if,else
and >,<,==
. But this method does not fit all fields, for example, the date input field, you need to accept dates only in the format 10/10/2020, if the input format does not match, it should give an error
Answer the question
In order to leave comments, you need to log in
Regex (\d{2}\.\d{2}\.\d{4})
(two digits + dot)+(two digits + dot)+(4 digits)
An example of finding such a date in your own text:
<?php
$re = '/(\d{2}\.\d{2}\.\d{4})/m';
$str = 'только в формате 10.10.2020, если формат ввода не совпадает, должно выдать ошибку';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question