-1

a simple regext that can test Either but atleast one of (http, https, or www).

I've seen examples that has compulsion of protocol, or allows directly like google.com.

but for users, they are used to typing www., not all would type the protocol. But still it should be a valid one, and not a "abced.com"

1
  • You haven't exactly explained what you're trying to accomplish here, but a simple google search would likely turn up some quick results (including ones here). Since this can be done many ways, here is one: (https?\:\/\/||www)[^\/$\s]+ from: regexr.com/38kqk and regexr.com/3c6nt Commented Apr 21, 2016 at 9:05

2 Answers 2

0

https://regex101.com/#javascript

there use (option1|option2|option3)

Sign up to request clarification or add additional context in comments.

Comments

0

If you just need to test if the url starts with http, https, www then you can simply use /^(https?|www)/.

If you need a full regex for the url then check out Mathias Bynens post on the matter https://mathiasbynens.be/demo/url-regex and pick the one most suited to your needs.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.