1

I have a forum on which users can use the CKEditor to make links. However, some users just post the raw url, resulting in some links nice formatted and some links not.

I'd like to make a filter based on a regex to make links of the raw urls. However, I'm stuck at making the regex. Requirements:

  • Matches http://... in normal HTML tags (<b>, <p>, blockquote, ...)
  • Does not match anything in the <a> tag
  • Does not match anything which is an HTML attribute (<a href="http://...">)

What regex can I use?

0

1 Answer 1

4

This technique is called linkification. It's to complex to do with just a regular expression. Luckily there good libraries for most languages.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.