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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:29:35+00:00 2026-05-16T12:29:35+00:00

I have the following as3 function below which converts normal html with links so

  • 0

I have the following as3 function below which converts normal html with links so that the links have ‘event:’ prepended so that I can catch them with a TextEvent listener.

protected function convertLinks(str:String):String
{
  var p1:RegExp = /href|HREF="(.[^"]*)"/gs;
  str = str.replace(p1,'HREF="event:$1"');
  return str;
}

For example

<a href="http://www.somedomain.com">

gets converted to

<a href="event:http://www.somedomain.com">

This works just fine, but i have a problem with links that have already been converted.

I need to exclude the situation where i have a string such as

<a href="event:http://www.somedomain.com"> 

put through the function, because at the moment this gets converted to

<a href="event:event:http://www.somedomain.com">

Which breaks the link.

How can i modify my function so that links with ‘event:’ at the start are NOT matched and are left unchanged?

  • 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-05-16T12:29:36+00:00Added an answer on May 16, 2026 at 12:29 pm

    First of all, trying to manipulate HTML with regex may not be a good idea.

    That said, according to the flavor comparison chart on regular-expressions.info, ActionScript regex is based off of ECMA engine, which supports lookaheads.

    Thus you can write this:

    /(?:href|HREF)="(?!event:)(.[^"]*)"/
    

    (?=…) is positive lookahead; it asserts that a given pattern can be matched. (?!…) is negative lookahead; it asserts that a given pattern can NOT be matched.

    Note that the inclusion of the . is very peculiar. It’s probably not intended to include the . there since it can match a closing doublequote.

    Note also that I’ve fixed the alternation for the href/HREF by using a non-capturing group (?:…).

    This is because:

    • this|that matches either "this" or "that"
    • this|that thing matches either "this" or "that thing"
    • (this|that) thing matches either "this thing" or "that thing"

    Alternatively you may also want to just turn on case-insensity flag /i, which would handle things like hReF or eVeNt:.

    Thus, perhaps your pattern should just be

    /href="(?!event:)([^"]*)"/gsi
    

    If lookahead was not supported, you can use an optional pattern that matches event: if it’s there, excluding it from group 1, so that it doesn’t get included when you substitute in $1.

    /href="(?:event:)?([^"]*)"/gsi
           \________/ \_____/
       non-capturing    group 1
         optional
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following AS3 code which converts a bunch of BitMap screenshots to
I have an AS3 program that calls a function multiple times. The function must
I have a function defined in AS3 that's gonna be called from client side
I have a calc function in java script that takes three integer parameters, following
I am hoping someone can help me. I have the following function in FlashBuilder
I have a function in my AS3 that frequently calls a PHP file. Most
I have the following array as3 example: var arrayDefinitionsargsAmfPhp:Array = new Array(); arrayDefinitionsargsAmfPhp['tabela'] =
I have the following two projects in in Flex Builder 3: One AS3 library
Hey all, basically i have an empty AS3 fla file with just the following
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>

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.