My application accepts the following type of URL
Example:
ABa12C.constant.com or
- (Optional)Starts with http:// or https:// or nothing.
- Should not start with integer(1aAb4.constant.com is invalid).
- In place of com it can be any like(in,uar,sr etc) but no integers.
My regular expression: [http://a-zA-Z0-9]{1,20}.constant.[a-zA-Z]{1,5}
But how to make http:// optional and can be used only at beginning and cannot be integer at beginning.
[http://a-zA-Z0-9]{1,20}? Try^(https?:\/\/)?[^0-9][a-zA-Z0-9]{0,19}\.constant\.[a-zA-Z]{1,5}$[http://a-zA-Z0-9]{1,20}? There is no any length restriction requirement listed in your question. Note that[^0-9]makes a non-digit compulsory.[^0-9]matches any character other than a digit. It matches~,\n,*,a,_, space. A lot of things.