JS regex simple url

I need a regex that will validate with these examples


I pulled this but doesn’t allow the . in .com or www.


  1. 1-9 ↩︎

With some examples from that web site?

Could you please be more specific about the examples strings of text that you need to validate.

I need

a url to validate that does not have the http://

just plain www.anyurl.com or just anyurl.com

very simple just not sure how to write regexs

The regex library is likely to be your best friend then.

For example, have a look at the first regular expression at the matches for url where it shows you some example successful matches, and non-successful matches.

Successful matches

non-successful matches

I’ve look at that site and those examples seem to give me syntax error in DW

You can test your regular expression over at the Regular Expression Tester page.
Which do you think is more likely to be wrong? A regular expression from a site that specialises in regular expressions, or a program like dreamweaver?

Dreamweaver is doing it wrong. It commonly does that.
Show us what you’re doing with Dreamweaver and we’ll try to help you through your problem.

I tried the one from that site but it gives me a syntax error like every other one i’ve gotten from there.

It also ruins the script

You may also find similar problems with many other regular expressions, because they all work in the same way.

Show us what you’re doing, and we’ll find out what’s going wrong.

simple validation script matching a reg ex

	  var $input = $(this); // define the input object with jQuery
		$('#weburl').addClass('green'); // an example of removing the class error from the input field
		$('#weburl').addClass('error'); // adding the error class if invalid content is entered

That code is saying that when you leave the ‘#CAT_Custom_194495’ field, that its value should be checked, and a different field called ‘#weburl’ should be coloured depending on the validity of the ‘#CAT_Custom_194495’ field. I’m not sure if that’s what you intend the code to do or not.

What is the HTML form code that the script is being used with?

Also, why is $input there? It doesn’t appear to be used by anything.

If your url is http://www.anyurl… you might drop the http://, but what about urls like http://anyurl … ? Do you want to drop the http:// in this case?

Looking back I see that you are prepared to accept anyurl.com or similar.

That worked. Thanks. I almost gave up having to explain the simplicity of this. I really need to learn how to write regexs.

Thanks so much

Is it only .com or .edu what if there is another ending like .net? I think I’d like it to end with either three or two letter to catch all endings:
Is this right as an ending?

.\d{3 | 2}$/

Can you write it up so it will accept 2 letters as well. It looks like it will but it doesn’t

I am using the second one that should work with both 2 or 3 letters at the end but it is not accepting the two letter.

example: kenaesthetic.me

check the form http://kenaesthetic.com/rfp.htm