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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:36:13+00:00 2026-05-26T08:36:13+00:00

How can I parse the string like Text=Andrey\’s Photos; Vacation;Font=Arial;Size=12 to the javascript object

  • 0

How can I parse the string like

Text=”Andrey\’s Photos; Vacation”;Font=Arial;Size=12

to the javascript object object like:

var options = {
  text: 'Andrey\'s Photos; Vacation',
  font: 'Arial',
  size: 12
}

My problem is that the value may contain ; and = characters, so I can not just use s.split(';'). But if there are such symbols in the values string, the value should be enclosed in single or double quotes. So the parsing of that string should be possible.

  • 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-26T08:36:14+00:00Added an answer on May 26, 2026 at 8:36 am

    Assuming the answer is no:

    var s = 'Text="Andrey\'s Photos; Vacation";Font=Arial;Size=12;SingleQuoted=\'The dog said "Foo"\'';
    var re = /(.*?)=(?:"(.*?)"|'(.*?)'|([^;]*?))(?:;|$)/g;
    var match;
    
    var options = {}
    while(match = re.exec(s))
    {  
        var string_val = match[2] || match[3] || match[4];
        var num_val = parseFloat(string_val);
        var val = isNaN(num_val) ? string_val : num_val;
        options[match[1].toLowerCase()] = val;
    }
    

    EDIT: Edited to allow using either ‘ or ” as delimiter. However, you still can’t escape.

    EDIT 2: Edited to use numeric type if applicable. Right now it just checks whether it can be coerced to a number, rather than trying to consider the quotes.

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

Sidebar

Related Questions

How can I parse the flash vars from a string like this? <script type=text/javascript>
How can I parse a string like 01-Jan-1995 to a Python datetime object?
I have code like: lblFranshizShowInvwNoskhehEdit.Text = string.Format({0:n}, (double)(int.Parse(drDarman[FranshizDarsad].ToString()) * Convert.ToInt64(RadNumerictxtPayInvwNoskhehEdit.Text)) / 100); But {0:n0}
I'm trying to use regexp to parse a string like similar to this: <tag>Text
I've got this javascript string: <!--:fr-->Photos<!--:--><!--:en-->Pictures<!--:--> And I need to parse it to get
How can I parse text and find all instances of hyperlinks with a string?
How can I parse the query string (GET / POST parameters) sent to an
Can Html Agility Pack be used to parse an html string fragment? Such As:
Does a tool exist that can parse text and output that text, hyper-linked to
Suppose I have a body of text (string) like this: str = 'This is

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.