0

Hi Can anyone tell me the regex for the below condition.

"https://abcd.ef" or "http://abcd.ef" is valid. this should not allow any spaces before "http" , "https" and after "ef". There can be any text after "ef". but the validation should not match in the below case.

"https://abcd.ef.ij k" --> since space is present between j and k-> validation should fail

" https://abcd.ef.ijk "-> since space is present in starting or trail -> validation should fail.

simply to put

[No spaces allowed][https:// or http://][and text or symbol].[any text or symbol for 2 words][optional text without no spaces in start or between or ending ]

Kumar
  • 183
  • 1
  • 12
  • /^\S*$/ This regex works perfectly for not allowing any spaces in the String.. but i would like to check this after this [No spaces allowed][https:// or http://][and text or symbol].[any text or symbol for 2 words] – Kumar Jul 30 '15 at 11:46
  • and i used below string to check pattern metioned in my above comment. /(((http|https):\/\/)?((([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@`~=%!]*)(\.\w{2,})?)*)|(localhost|LOCALHOST))\/?)/i – Kumar Jul 30 '15 at 11:49
  • just add anchors, `^` at the start and `$` at the end. – Avinash Raj Jul 30 '15 at 11:51

0 Answers0