JavaScript Fix Up Regex To Not Re-Grab Old URLs From Text (JS) regex grab url,regex extract urls,regex extract urls from

Currently I am writing my own BBCode parser. More specifically I am working on the links.

You can click on the link button, and it will insert a link (HTML <a>) around your text. Then that text will of course be clickable.

If you just normally write a link in the textarea, it will also make that a link automatically. Let me give you some example of what I mean so far:

 http://stackoverflow.com 
 Changes Automatically To
 <a target='_blank' href="http://stackoverflow.com">http://stackoverflow.com</a>

 If the user clicks the link button, and inserts it around text:
 [link=http://stackoverflow.com]Directs to SO[/link]
 It will then change that to
 <a target='_blank' href="http://stackoverflow.com">Directs to SO</a>

Ok now hopefully you still understand what is going on (I know I am confusing). Here in-lies the problem, the regex that changes the BBCODE > HTML is doing it twice.

Before I continue on this let me show you my regexs:

.replace(/(\[code\][\s\S]*?\[\/code\])|\[(link=)((http|https):\/\/[\S]{0,2000}\.[a-zA-Z]{2,5}(\/[^\[\]\<\>]*)?)\]([\s\S]*?)\[\/link\]/gi, function (m, g1, g2, g3, g4, g5, g6) { return g1 ? g1 : '<a target='_blank' href="' + g3 + '">' + g6 + '</a>'; }) 
.replace(/(\[code\][\s\S]*?\[\/code\])|((http|https):\/\/[\S]{0,2000}\.[a-zA-Z]{2,5}(\/[^\[\]\<\>]*)?)/gi, function (m, g1, g2, g3, g4, g5) { return g1 ? g1 : '<a target='_blank' href="' + g2 + '">' + g2 + '</a>'; })

So basically as you can see, that converts URLS to clickable links. The [link=___] is not working though because the second regex is trying to rewrite the first regex again. Let me show you what I mean:

[link=http://stackoverflow.com]Directs to SO[/link]
First Regex Makes It This:
<a target='_blank' href="http://stackoverflow.com">Directs to SO</a>
Second Regex Then Makes It This:
<a target='_blank' href="<a target='_blank' href="http://stackoverflow.com">Directs to SO</a>

So as you can see it is trying to convert the URLs twice.

How could I make the SECOND regex not change URLS in the [link] tag a second time?

Answer:1

i tried to get the image src with jquery here is the code below jQuery("img").click(function() { var im = $(this).attr('src'); alert(im); return false; }); above working fine i can get ...

i tried to get the image src with jquery here is the code below jQuery("img").click(function() { var im = $(this).attr('src'); alert(im); return false; }); above working fine i can get ...

  1. get href value of anchor tag in jquery
  2. get href value of anchor tag in javascript
  3. get href value from anchor jquery
  4. how to get href value of anchor tag in jquery
  5. how to get href of anchor tag in jquery
  6. get href of anchor tag in jquery

I am trying to move an image (its a picture of a map) inside its container so a specific part of the image(a city) is in the center of its container when a div is clicked. I have this working but the ...

I am trying to move an image (its a picture of a map) inside its container so a specific part of the image(a city) is in the center of its container when a div is clicked. I have this working but the ...

  1. jquery animate left position
  2. jquery animate left to right
  3. jquery animate left to right slide example
  4. jquery animate left not working
  5. jquery animate left percentage
  6. jquery animate left
  7. jquery animate left to right slide
  8. jquery animate left to right loop
  9. jquery animate left slide
  10. jquery animate left toggle
  11. jquery animate left doesn't work
  12. jquery animate left to right toggle
  13. jquery animate left to right continuous
  14. jquery animate left auto
  15. jquery animate left 100
  16. jquery animate left right up down
  17. jquery animate left margin
  18. jquery animate left to right infinite
  19. jquery animate left position change
  20. jquery animate left fadeout

With this code, my chart is resizing when I drag the window, but not when I press the maximize button on windows or the full screen button on mac. Is this just a chart.js problem? Here is my JS for ...

With this code, my chart is resizing when I drag the window, but not when I press the maximize button on windows or the full screen button on mac. Is this just a chart.js problem? Here is my JS for ...

Here's what I have in mind: Given an array of objects: [ { "name": "Kirk", "count": 1 }, { "name": "Spock", "count": 1 }, { "name": "Kirk",...

Here's what I have in mind: Given an array of objects: [ { "name": "Kirk", "count": 1 }, { "name": "Spock", "count": 1 }, { "name": "Kirk",...

  1. remove duplicate objects from array javascript
  2. remove duplicate objects from list java
  3. remove duplicate objects from list c#
  4. remove duplicate objects from array javascript es6
  5. remove duplicate objects from list java 8
  6. remove duplicate objects from array lodash
  7. remove duplicate objects from list python
  8. remove duplicate objects from array java
  9. remove duplicate objects in arraylist java
  10. remove duplicate objects from arraylist
  11. remove duplicate objects from array swift 4
  12. remove duplicate objects from arraylist in java 8
  13. remove duplicate objects from array javascript reduce
  14. remove duplicate objects from array typescript
  15. remove duplicate objects from array php
  16. remove duplicate objects from list
  17. remove duplicate objects from array react
  18. remove duplicate objects in array js
  19. remove duplicate objects from array jquery
  20. remove duplicate objects from array c#