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

  • Home
  • SEARCH
  • 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 605835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:11:21+00:00 2026-05-13T17:11:21+00:00

I have to parse out color information from HTML data. The colors can either

  • 0

I have to parse out color information from HTML data. The colors can either be RGB colors or file names to a swatch image.

I used http://www.gskinner.com/RegExr/ to develop and test the patterns. I copied the AS regular expression code verbatim from the tool into Flex Builder. But, when I exec the pattern against the string I get a null.

Here are the patterns and an example of the string (I took the correct HTML tags out so the strings would show correctly):

DIV data:

<div style="background-color:rgb(2,2,2);width:10px;height:10px;">

DIV pattern:

/([0-9]{1,3},[0-9]{1,3},[0-9]{1,3})/

IMG data:

<img src="/media/swatches/jerzeesbirch.gif" width="10" height="10" alt="Birch">

IMG pattern:

/[a-z0-9_-]+/[a-z0-9_-]+/[a-z0-9_-]+\.[a-z0-9_-]+/

Here’s my Actionscript code:

var divPattern : RegExp = new RegExp("/([0-9]{1,3},[0-9]{1,3},[0-9]{1,3})/");
var imgPattern : RegExp = new RegExp("/[a-z0-9_-]+/[a-z0-9_-]+/[a-z0-9_-]+\.[a-z0-9_-]+/");

var divResult : Array = divPattern.exec(object.swatch);
var imgResult : Array = imgPattern.exec(object.swatch);  

Both of the arrays are null.

This is my first foray into AS coding, so I think I’m declaring something wrong.

Steve

  • 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-13T17:11:22+00:00Added an answer on May 13, 2026 at 5:11 pm

    (I don’t know ActionScript but I know Javascript and they should be close enough to solve your problem.)


    To construct a RegExp object for e.g. the pattern ^[a-z]+$, you either use

    var pattern : RegExp = new RegExp("^[a-z]+$");
    

    or, better,

    var pattern : RegExp = /^[a-z]+$/
    

    The code new RegExp("/^[a-z]+$/") is wrong because this expects a slash before the ^ and after the $.


    Therefore, your DIV pattern should be written as

    var divPattern : RegExp = /([0-9]{1,3},[0-9]{1,3},[0-9]{1,3})/;
    

    but, as you know, the ( and ) are special characters for capturing, you need to escape them:

    var divPattern : RegExp = /\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\)/;
    

    For the IMG pattern, as / delimitates a RegEx, you need to escape it as well:

    var imgPattern : RegExp = /[a-z0-9_-]+\/[a-z0-9_-]+\/[a-z0-9_-]+\.[a-z0-9_-]+/
    

    Finally, you could use \d in place of [0-9] and \w in place of [a-zA-Z0-9_].

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

Sidebar

Related Questions

I have the following HTML text : Country/<i>List it here</i><br><font color=#ff00ff>Dubai</font><br><br> How do I
I'm trying to figure out how to better parse lines of text that have
I have a feed with images in the description node. How can I parse
i am trying to parse out a string and in some cases there is
Hey i'm curious as to how to parse out the host name in a
Greetings All, I need to optimize a RegEx I am using to parse template
I am getting the value from web service like &gt;&lt;&amp;&nbsp; etc. I want to
I have two flash movies fl_base and fl_top . fl_base contains ActionScript that pulls
I was trying to use a random number generator in a windows forms app,
I'm parsing a string that follows a predictable pattern: 1 character an integer (one

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.