I have a regex that works perfectly with the numbers I want to get, but the problem is with the URLs that also get them, how could I do to remove them?
Skip if there is no blank space, line break or the like?
Thanks !!
my current regex is:
/((?(0{1,2}|+)\d{1,2})?)?(([ -]*\d+){8,20})+/gm
https://regex101.com/r/yzAScj/1
the modification I made doesn't work:
/\s{1}((?(0{1,2}|+)\d{1,2})?)?(([ -]*\d+){8,20})+\s{0,1}/gm
https://regex101.com/r/yzAScj/2
Test text:
https://asd.com/20441235534-aaaaaaaaaaa-
202460676
aasdasd 202460676
https://asd.com/20441235534
202460676-
10 text
1234 text
text 123
00491234567890
+491234567890
0123-4567890
0123 4567 789
0123 456 7890
0123 45 67 789
+490123 4567 789
+490123 456 7890
+49 123 45 67 789
123 4567 789
123 456 7890
123 45 67 789
+49 1234567890
+491234567890
0049 1234567890
0049 1234 567 890
(0049)1234567890
(+49)1234567890
(0049) 1234567890
(+49) 1234567890
text text (0049) 1234567890 text text
text text (+49) 1234567890 text text
makes the phone numbers have the link "tel:" to be able to click on them.
You shouldn't pick a URL as a phone.
JS code (with jquery):
function searchAndReplacePhones(){
var regex = /(\(?(0{1,2}|\+)\d{1,2}\)?)?(([ -]*\d+){8,20})+/gm;
//Beschreibung
$(".my_text").html($(".my_text").html().replace(regex, " <a href=\"tel:$&\">$&</a> "));
}