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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:43:45+00:00 2026-05-30T14:43:45+00:00

In ActionScript3 i wanted to get the text between 2 quotes from some HTML

  • 0

In ActionScript3 i wanted to get the text between 2 quotes from some HTML using a input index value where i would simply increase the 2nd quote characters value by 1. This would be very simple however i have now noticed using indexOf does not seem to work correctly with quotes and other special characters.

So my question is if you have some HTML style text like this:

var MyText:String = '<div style="text-align:center;line-height:150%"><a href="http://www.website.com/page.htm">'; 

How can i correctly get the index of a quote ” or other special character?

Currently i try this:

MyText.indexOf('"',1)

but after 0 it always returns the wrong index value.

Also a quick additional question would be is there a better way than using ‘ ‘ to store strings with characters like ” inside? So if i had other ‘ characters etc it won’t cause problems.

Edit –

This is the function i had created (usage = GetQuote(MyText,0) etc)

        // GetQuote Function (Gets the content between quotes at a set index value)
        function GetQuote(Input:String, Index:Number):String {
            return String(Input.substr(Input.indexOf('"', Index), Input.indexOf('"', Index + 1)));
        }

The return for GetQuote(MyText,0) is “text-align yet i need text-align:center;line-height:150% instead.

  • 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-30T14:43:46+00:00Added an answer on May 30, 2026 at 2:43 pm

    First off, index of the first quote is 11 and both MyString.indexOf('"') and MyString.indexOf('"',1) return the right value (the latter also works because you don’t actually have a quote at the beginning of your string).

    When you need to use an single quote inside another one or a double quote inside another one you need to escape the inner one(s) using backslashes. So to catch a single quote you would use it like '\''

    There are several ways of stripping a value from a string. You can use the RegExp class or use standard String functions like indexOf, substr etc.

    Now what exactly would you like the result to become? Your question is not obvious.

    EDIT:

    Using the RegExp class is much easier:

    var myText:String = '<div style="text-align:center;line-height:150%"><a href="http://www.website.com/page.htm">';
    
    function getQuote(input:String, index:int=0):String {
    // I declared the default index as the first one
        var matches:Array = [];
        // create an array for the matched results
        var rx:RegExp = /"(\\"|[^"])*"/g;
        // create a RegExp rule to catch all grouped chars
        // rule also includes escaped quotes
        input.replace(rx,function(a:*) {
            // if it's "etc." we want etc. only so...
            matches.push(a.substr(1,a.length-2));
        });
        // above method does not replace anything actually.
        // it just cycles in the input value and pushes
        // captured values into the matches array.
        return (index >= matches.length || index < 0) ? '' : matches[index];
    }
    
    trace('Index 0 -->',getQuote(myText))
    trace('Index 1 -->',getQuote(myText,1))
    trace('Index 2 -->',getQuote(myText,2))
    trace('Index -1 -->',getQuote(myText,-1))
    

    Outputs:

    Index 0 –> text-align:center;line-height:150%
    Index 1 –> http://www.website.com/page.htm
    Index 2 –>
    Index -1 –>

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

Sidebar

Related Questions

In ActionScript3, how do you get a reference to an object's class?
I'm creating an Illustrator plugin using Actionscript and I wanted that as soon as
I'm using ActionScript3 to develop a Data Access Layer for an application another developer
i wanted to know that using actionscript, is it possible to send email and
This question if a bit off topic, I just wanted feedback from most ActionScript/Flex
In actionscript3 I am able to create a p2p network and send arbitary text
Using ONE Sound() object in Actionscript3, how can I play a one MP3 and
Just wanted to ask if there is any advantage for either using mouse click
I come from an Actionscript3 background and this is my first time writing any
im new to actionscript3 flash. I have a int variable and i would like

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.