+ 1

Please help. How to find that the user entered web address

I'm creating a chat app. if a user enters a web address and submits the message, how to find that the user entered a web address. And if the user entered ordinary message rather than web address how to display it normally. Thanks in advance.

20th Jul 2018, 2:55 PM
Vj Abishek
Vj Abishek - avatar
2 odpowiedzi
+ 2
Try this var str='google.com'; var regex = new RegExp(/[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi); if(regex.test(str)) alert(true); else alert(false); source https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
20th Jul 2018, 3:24 PM
ᴋᵘⁿᵃˡ
ᴋᵘⁿᵃˡ - avatar
0
thanks Kunal Thakur. It's working
21st Jul 2018, 1:56 AM
Vj Abishek
Vj Abishek - avatar