The regular expression matches the first 3 characters of a string in PHP

I am looking for a regular expression pattern that matches the first character of a string.
For example, I have two numbers: 011569875and 041568956
If I find the first character 3 011, then Iโ€™ll print011569875

+4
source share
1 answer

As suggested by @Mark, you can use substras follows:

$string = substr($longstring,0,3);
if($string == '011'){
   echo $longstring;
}

Hope this helps. Greetings

+2
source

Source: https://habr.com/ru/post/1610631/


All Articles