Match url beginning with http:// or nothing.

H

Heckner

Hi

I tried /(http:\/\/w+|^§)/ as the regex for matching an url beginning
with http:// or an empty string.
Problem is the empty string is not matched. Any idea?
Best regards
Hannes
 
E

echohtp

well im not sure what it is but that "empty string" character is either
wrong or just displaying wrong here, this is what you would want

/(http:\/\/\w+|\s+)/ you missed the \ for the w+ and the s+ hopefully
this will fix your problem :)
 
G

Gunnar Hjalmarsson

Heckner said:
I tried /(http:\/\/w+|^§)/ as the regex for matching an url beginning
with http:// or an empty string.
Problem is the empty string is not matched. Any idea?

It matches a section sign as expected. You mean

/(http:\/\/w+|^$)/
-------------------^
 
S

Sherm Pendley

Gunnar Hjalmarsson said:
It matches a section sign as expected. You mean

/(http:\/\/w+|^$)/
-------------------^

In addition, you could avoid "leaning toothpick syndrome" by using a different
delimiter for the match:

m%(http://w+|^$)%

sherm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top