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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:33:42+00:00 2026-06-12T03:33:42+00:00

I have some troubles with this regular expression in javascript. That same regex works

  • 0

I have some troubles with this regular expression in javascript. That same regex works in PHP, but in JavaScript this error occurs: “Invalid regular expression: unrecognized character after (?”. My regular expression is:

text = text.replace(/(?<!\=\")http([A-Za-z0-9:\/\.\+\?\%\@\!\#\&_-]+)/g,
    '<a href="http$1" target="_blank" rel="nofollow">http$1</a> ');

The problem is in first part (?< !\=\") but I don’t know how to solve it because it is a normal regular expression for PHP or C.

Is there any analog of this construction? I need to disallow symbol " (double quotes) right before “http” for preventing url replacements in html elements like <img>.

I’m edit the question because the symbols < plus ! make an error in displaying text after it. (that, may also invoke error).

  • 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-12T03:33:44+00:00Added an answer on June 12, 2026 at 3:33 am

    In your example above (including adding the ):

    var text = 'something bla bla bla like this domain.com/blabla/bla.php or more. <img src="img.com" />'
    

    This would work for you:

    var newText = text.replace(/([^ ]*\.com\/[^ ]*)/g,'<a href="http://$1"; target="_blank" rel="nofollow">$1</a>');
    

    And outputs:

    something bla bla bla like this <a href="http://domain.com/blabla/bla.php"; target="_blank" rel="nofollow">domain.com/blabla/bla.php</a> or more. <a img src="img.com" />
    

    Basically it recognizes the url by anything not a space in front of a .com/ plus anything afterwards not a space. It won’t grab the <img src="img.com" /> as that’s a .com".

    If you only have .com domains this will work, if you have .net, .org, etc, etc. then you’ll have to add those as things to check.

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

Sidebar

Related Questions

I have some troubles with this small JavaScript code: var text=Z Test Yeah !
I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with positioning my label/password field. With this code they both
I'm having some trouble figuring this out. I have an unordered list menu that
I have some troubles installing air files that've been built with air2.0beta or air2.0beta2
I have an aspx page that contains regular html, some uicomponents, and multiple tokens
I have some troubles with the application of polymorphism in this example. This question
I am having some trouble with this regular expression, Can somebody maybe assist me
i have some troubles implementing this layout: http://deconcini.net/maurer-schneebacher/projekte/elisabethinum.html Basically i would like to display
I am struggling to understand this simple regular expression. I have the following attempt:

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.