Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I do not know how Action Script regexes work, but noting that attributes can appear anywhere in the tag, you can substitute <code>&lt;a target="_blank" href=</code> for every <code>&lt;a href=</code>. Something like this maybe:</p> <pre><code>var pattern:RegExp = /&lt;a\s+href=/g; var str:String = "&lt;a href=\"http://stackoverflow.com/\"&gt;"; str.replace(pattern, "&lt;a target=\"_blank\" href="); </code></pre> <p>Copied from Adobe docs because I do not know much about AS3 regex syntax.</p> <p>Now, manipulating HTML through regex is usually very fragile, but I think you can get away with it in this case. First, a better way to style the link would be through CSS, rather than using the <code>&lt;font&gt;</code> tag:</p> <pre><code>str.replace(pattern, "&lt;a style=\"color:#00d\" target=\"_blank\" href="); </code></pre> <p>To surround the link with other tags, you have to <strong><em>capture</em></strong> everything in <code>&lt;a ...&gt;anchor text&lt;/a&gt;</code> which is fraught with difficulty in the general case, because pretty much anything can go in there.</p> <p>Another approach would be to use:</p> <pre><code>var start:RegExp = /&lt;a href=/g; var end:RegExp = /&lt;\/a&gt;/g; var str:String = "&lt;a\s+href=\"http://stackoverflow.com/\"&gt;"; str.replace(start, "&lt;font color=\"#0000dd\"&gt;&lt;a target=\"_blank\" href="); str.replace(end, "&lt;/a&gt;&lt;/font&gt;"); </code></pre> <p>As I said, I have never used AS and so take this with a grain of salt. You might be better off if you have any way of manipulating the DOM.</p> <p>Something like this might appear to work as well:</p> <pre><code>var pattern:RegExp = /&lt;a\s+href=(.+?)&lt;\/a&gt;/mg; ... str.replace(pattern, "&lt;font color=\"#0000dd\"&gt;&lt;a target=\"_blank\" href=$1&lt;/a&gt;&lt;/font&gt;"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload