Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:58:20+00:00 2026-05-29T08:58:20+00:00

I have a regular expression which will parse the content of a message and

  • 0

I have a regular expression which will parse the content of a message and convert plain text hyperlinks into HTML hyperlinks.

message = message.replaceAll("(?:https?|http?)://[\\w/%.\\-?&=!#]+",
                             "<a href='$0' target='_blank'>$0</a>");

It is fine when converting http or https hyperlinks.

The problem is that I also have other hyperlinks enclosed within bbcode tags which I do not want the regular expression to converted into HTML hyperlinks.

E.g. [IMG]http://www.google.com/img.png[/IMG] or [YOUTUBE]http://www.youtube.com[/YOUTUBE]

How do I change my regular expression to prevent the regex from converting bbcode hyperlinks?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:58:21+00:00Added an answer on May 29, 2026 at 8:58 am

    You can use negative lookbehind.

    "(?<!\])(?:https?|http?)://[\\w/%.\\-?&=!#]+"
    

    The (?<!\]) will only allow the rest of the URL pattern to match if it does not immediately follow a ']'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I please have a regular expression in .NET, which will allow only 24
The regular expression which I have provided will select the string 72719 . Regular
I'm stuck on a regular expression. I have tons of text which is full
I have the following regular expression which is used to give me the tags
I have a regular expression ^[a-zA-Z+#-.0-9]{1,5}$ which validates that the word contains alpha-numeric characters
I have a Python regular expression that contains a group which can occur zero
I am trying to create a regular expression which will look for a email
I have a variable which will contain a relative URL (i.e. ../test.html) and I
I have a text file which I'm trying to parse. The file looks like
I understand that CDT 7 will have a regular expression error parser included, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.