Javascript : Create regex for Url match -


regex : (^|\s)((https?://)?[\w-]+(.[\w-]+)+.?(:\d+)?(/\s*)?)

above regex should not pass below url.

www.google

test criteria:

match:

pass: http: //example.com
pass: http: //example.com/
pass: http: //example.com/super
pass: https: //example.com/super/
pass: example.com/super
pass: example.com
pass: example.com/su-per_duper/?add=yes&subtract=no
pass: example.com/archive/index.html
pass: twitter.com/#!/reply
pass: example.com/234ret2398oent/234nth
pass: codegolf.stackexchange.com/questions/464
pass: crazy.wow.really.example.com/?cat=nth%3e
pass: example-example.com
pass: example1.com

not match(this working correctly):

pass: example
pass: super/cool
pass: morning
pass: i:can
pass: hello.

here test might clarify bit https://regex101.com/r/pdgwy6/5

i apologize lack of clarity,please me.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -