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

  • SEARCH
  • Home
  • 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 8001129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:00:33+00:00 2026-06-04T16:00:33+00:00

I created a regular expression that reads a string and transforms found url’s into

  • 0

I created a regular expression that reads a string and transforms found url’s into HTML links. I wanted to exclude the dot at the end of a line (containing the text link) but it also excludes the dot inside the text link (like in http://www.website.com/page.html.) The end dot here should be excluded but not the .html. This is my regex:

    $text = preg_replace("#(^|[\n  \"\'\(<;:,\*])((www|ftp)\.+[a-zA-Z0-9\-_]+\.[^ \"\'\t\n\r< \[\]\),>;:.\*]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $text);                        

How would one do that?

Thanx! Tom

  • 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-06-04T16:00:35+00:00Added an answer on June 4, 2026 at 4:00 pm

    Change your RegEx to this

    \b((?#protocol)https?|ftp)://((?#domain)[-A-Z0-9.]+)((?#file)/[-A-Z0-9+&@#/%=~_|!:,.;]*)?((?#parameters)\?[A-Z0-9+&@#/%=~_|!:,.;]*)?
    

    or this

    \b((?:https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]*)\b
    

    Explanation

    "
    \b                            # Assert position at a word boundary
    (                             # Match the regular expression below and capture its match into backreference number 1
                                     # Match either the regular expression below (attempting the next alternative only if this one fails)
          http                          # Match the characters “http” literally
          s                             # Match the character “s” literally
             ?                             # Between zero and one times, as many times as possible, giving back as needed (greedy)
       |                             # Or match regular expression number 2 below (attempting the next alternative only if this one fails)
          ftp                           # Match the characters “ftp” literally
       |                             # Or match regular expression number 3 below (the entire group fails if this one fails to match)
          file                          # Match the characters “file” literally
    )
    ://                           # Match the characters “://” literally
    [-A-Z0-9+&@#/%?=~_|\$!:,.;]    # Match a single character present in the list below
                                     # The character “-”
                                     # A character in the range between “A” and “Z”
                                     # A character in the range between “0” and “9”
                                     # One of the characters “+&@#/%?=~_|\$!:,.;”
       *                             # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
    [A-Z0-9+&@#/%=~_|\$]           # Match a single character present in the list below
                                     # A character in the range between “A” and “Z”
                                     # A character in the range between “0” and “9”
                                     # One of the characters “+&@#/%=~_|\$”
    "
    

    Hope this helps.

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

Sidebar

Related Questions

I've created a regular expression that matches any numeric value (with leading or trailing
I'd like to create a regular expression that will match and return based on
Is it possible to create a regular expression that matches a comparison such as
I'm no expert on Regex. I'm trying to create a regular expression that will
this one is really easy. I'm trying to create a Regular Expression that will
I created this regular expression to validate names: ^[a-zA-Z0-9\s\-\,]+.\*?$ Is there a way add
I don't get it. I created this regular expression: <span class=copy[Green|Red].*>[\s]*(.*)[\s]*<\/span> to match certain
Here is a regular expression I created to use in JavaScript: var reg_num =
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I am trying to create a regular expression with a character class that has

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.