Jump to content

In a text there's (possibly) one URL inside <a> tags. Need to validate that URL.


Recommended Posts

The user submits some text that, to his/her discretion can contain a url in the form of <a href="someurl">some text</a>.

 

I need to know if "someurl" is a valid url.

 

Consider that:

the "<a>" tag and the url might not even be there;

a crazy user might even have created more than one url;

 

I cannot run a regex to extract URLs from text (I found some on the web) because that regex naturally looks for valid URLs: but the url I am looking for (if any) is invalid!

 

The only clue I think is the presence of the "<a>" tags. Found those, the regex should look for the "href" attribute tags and then validate.

I'm no good at regex and can't say how all this should happen.

 

Any ideas?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.