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 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 to parse a tab-delimited text file with Ruby to extract some data
I have a binary file that I have to parse and I'm using Python.
I have a problem which requires me to parse several log files from a
I have a huge file that I must parse line by line. Speed is
I'm trying to figure out a way to parse out a base64 string from
I'm trying to figure out a way to parse out a base64 string from
For a small project I have to parse pdf files and take a specific
My application receives strings that represent objects. I have to parse the strings to
Is there a easy way to do this? Or do I have to parse
I have a class to parse a matrix that keeps the result in an

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.