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 9147707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:03:50+00:00 2026-06-17T11:03:50+00:00

I saw a few posts on this but they were for PHP (I need

  • 0

I saw a few posts on this but they were for PHP (I need JavaScript (actually ActionScript (…because ActionScript extends JavaScript))) so my question is how to only capture up to a comma, period, question mark or exclamation point.

This is what I have so far,

instructionText.replace(/(https?:\/\/\w.*[\w])/gi, "<a href='$1' target='_blank'>$1</a>");

But when I use the text, “Visit http://www.google.com. Hello world” it captures the hello world part.

The result of the capture group above is “http://google.com. Hello world “. Obviously I don’t want anything after the URL. They should be simple URL’s.

Mainly, I just want to add a check for any of these “.,!?” or a space character and end the capture group. It doesn’t have to be perfect.

BTW Not sure if you have something to test your RegEx first but if not you can use RegExr.

  • 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-17T11:03:51+00:00Added an answer on June 17, 2026 at 11:03 am

    Assuming no space in the urls and a space or end of string after them:

    instructionText.replace( /(https?:\/\/\S+?)(?=[.,!?]?(\s|$))/g, "<a href='$1' target='_blank'>$1</a>" );
    

    It captures ‘http[s]://’ and non-space characters as few times as possible until looking ahead there is optionally one of .,!?, and then a space or the end of string.

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

Sidebar

Related Questions

So I have looked around and saw a few posts on similar things but
NB: I saw a few questions being asked in this front, but none seem
I saw many threads with this tittle, but no one really speak about reuse
I have looked into a few posts and saw some related posts on it
I searched SO and saw a few questions posted on the topic, but I
I am using https with php and have a few security questions: +I saw
I saw quite a few other posts related to EXC_BAD_ACCESS signals right on glDrawArrays,
I saw a few answers to this issue, and I get it — you
I saw a few posts about get columns from subqueries, most of them suggest
I saw a few posts similar to my problem and tried the solutions offered,

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.