jrahma
August 30, 2017, 9:41pm
1
Hi,
How can I make a reguluar expression pattern which accepts websites only but includes all type of website domains, e…g [dot]online, [dot]co, [dot]com, http, https, etc…
I tried below but it’s not working with many domains
/^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/
Thanks,
Jassim
ronpat
August 31, 2017, 12:36am
2
Try this: (The following regex is written for a text editor, not JS.)
\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]
Samples: matches are yellow, not matched are not colored.
IF you cannot work with this, then supply a full range of samples showing exactly what you need to capture and what to do not wish to capture.
[off topic]
My knowledge of regex is severely limited and if Php was available I would use:
'sitepoint'===$_SERVER['SERVER_NAME']
What am I missing?
[/Off topic]
Edit:
Replaced incorrect session with server.
SamA74
August 31, 2017, 4:56pm
4
Is this for client side validation of an input? You could just use type="url"
in that case.
system
Closed
November 30, 2017, 11:57pm
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.