[a-z\%\/\-\(\)\s]?\d{3}[a-z\%\/\-\(\)\s]?\d{3}[a-z\%\/\-\(\)\s]?\d{4}[a-z\%\/\-\(\)\s]?
My above regex is what I've come up with. But I need something that can detect a few more patterns of numbers, and then, once the numbers are matched, remove all other texts, letters, chars in the line but the numbers. below is my regex.
I really need help with this been looking forever.
https://www.regex101.com/r/hT5eD9/1
FIXED
You can take this approach:
Match 1 or more non-digits that are followed by digits on either side to detect non-digits in between digits and remove them.
Using this regex:
(?<=\d)[^\d
]+(?=\d)
Code:
$result = preg_replace("~(?<=\\d)[^\\d\
]+(?=\\d)~", '', $input);
How about this?
<?
if(is_numeric($str)){
//str is a number
}
Try this: regex pattern ([^\d\s]+|\s\d{1,2}[\s\,])*(\d{3}[^\d ]*\d{3}[^\d ]*\d{4})*([^\d\s]+|\s\d{1,2}[\s\,])*
You search ([^\d\s]+|\s\d{1,2}[\s\,])*(\d{3}[^\d ]*\d{3}[^\d ]*\d{4})*([^\d\s]+|\s\d{1,2}[\s\,])*
and replace with $2
. it will works for your condition.
Update: