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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:01:19+00:00 2026-05-20T14:01:19+00:00

Ok perhaps ive bitten off too much here… I know you are not supposed

  • 0

Ok perhaps ive bitten off too much here…
I know you are not supposed to parse xml/html to regex but the thing is there just arent many other options.
Im using AS3
im parsing the source of textflowlayout text to a different format.

string to parse :

< fontFamily=Verdana encoding=unicode fontWeight="bold"> some text < fontFamily=Verdana encoding=unicode > some text < fontFamily=Arial encoding=unicode fontStyle="italic"> some text < fontFamily=Arial encoding=unicode fontWeight="bold" fontStyle="italic"> some text 

what i really need is:

< fontname=Verdanabold encoding=unicode> some text < fontname=Verdana encoding=unicode > some text < fontname=Arialitalic encoding=unicode > some text < fontname=Arialbolditalic encoding=unicode > some text

logically i think of it as taking apart the string into substrings
checking if there are fontWeight or fontStyle in the substring
if there is then appending the font name with the weight or style so so that the font name becomes font NameWeightStyle.
then rebuilding the string.
The font could be any font with variouse styles or weights.

Or please any other bright ways to do this will be appreciated.

so far:

pattern =   /<(.*?)>/gixsm;
var matches:Object = pattern.exec(str);
var finalstring:String = "";
for each ( var i:String in matches ) {

    if(i!='0'){
        Alert.show(i);
    pattern = /fontFamily=\"([^"]*)"/i;
    if(pattern.test(i)==true){
        pattern = /fontFamily=\"([^"]*)\" /i;
        var resultfontFamily:Object = pattern.exec(i);
        var fontFamily:String = resultfontFamily[1].toString();



        /*pattern = /fontWeight=\".*?\" /i;
        if(pattern.test(i)==true){

            pattern = /fontWeight=\"([^"]*)\" /i;
            var resultfontWeight:Object = pattern.exec(i);
            var fontWeight:String  = resultfontWeight[1].toString();
            fontFamily = fontFamily+fontWeight;

        }
        pattern = /fontStyle=\"([^"]*)\" /i;
        if(pattern.test(i)==true){

            pattern = /fontStyle=\"([^"]*)\" /i;
            var resultfontStyle:Object = pattern.exec(i);
            var fontStyle:String  = resultfontStyle[1].toString();
            fontFamily = fontFamily+fontStyle;

        }*/
        fontFamily = "fontname="+fontFamily+" encoding=unicode";
        pattern = /fontFamily=\".*?"/i;
        finalstring += i.replace(pattern, fontFamily);

    }
    }

}
str = finalstring;

a few things
1 – the pattern to create the match object
/<(.*?)>/gim; or /<([^<])+?>/gim;
doesnt seem to work in as3 as an accurate gatherer of strings to array/object for this string???

2 assuming we have to put this sting back together – how would I access the “some text”?

any suggestions most welcome –
much appreciated
M

  • 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-20T14:01:19+00:00Added an answer on May 20, 2026 at 2:01 pm

    You’re question is a bit ambiguous – i.e. you do not clearly specify if both the Style and Weight may both appear in a single tag. Also, you do not specify the whitespace and attribute value quoting requirements. That said, the following (javascript syntax) code should do the trick for just about any case:

    p1 = /(<\s*fontname\s*=\s*)(['"]?)([^\s'"]+)(['"]?)([^>]*?)\s+fontWeight\s*=\s*['"]?([^\s'"]*)['"]?/ig;
    p2 = /(<\s*fontname\s*=\s*)(['"]?)([^\s'"]+)(['"]?)([^>]*?)\s+fontStyle\s*=\s*['"]?([^\s'"]*)['"]?/ig;
    str = str.replace(p1, "$1$2$3$6$4$5");
    str = str.replace(p2, "$1$2$3$6$4$5");
    

    Hopes this helps! 🙂

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

Sidebar

Related Questions

Here's something I haven't been able to fix, and I've looked everywhere . Perhaps
Perhaps I am not asking or searching for this correctly: I want to have
Perhaps not directly programming related, but definitely product / commercially related. And I can't
Perhaps naively, I created a class (AdminDatabase) to handle connection to different MS-Access database
Perhaps this is a naive question. In my understanding, ASP.NET MVC cannot work with
Perhaps I'm missing something with the concept of Extension Methods, but I cannot gain
Perhaps my question is similar in nature to this one: Do you use design
Perhaps I am missing something, but I am just learning javascript. My understanding of
Or perhaps this is a manual install only deal.
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can

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.