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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:39:41+00:00 2026-05-16T01:39:41+00:00

I have a string that represents a list of tags separated by space. It

  • 0

I have a string that represents a list of tags separated by space. It may look like this:

Australia 2010 David November Family

If a tag contains at least one space, it must be quoted. So the string can be:

"Best Friends" "My Pictures" Wow "Very Nice Photo" University

Quotes are also allowed for single words. For example:

"Good One" Fantastic "February" "My Family" "Friends"

The question is:
How would you get an array of tags from the string ?
For example, from the third string I would like to get the following array:

arr[0] = "Good One"
arr[1] = "Fantastic"
arr[2] = "February"
arr[3] = "My Family"
arr[4] = "Friends"

If the string is not in the right format, I would like to know about it (for example: to get empty array as a result).

  • 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-16T01:39:42+00:00Added an answer on May 16, 2026 at 1:39 am

    You can use a regular expression like /"[^"]+"|\w+/ to match the tags.
    To get an array containing all the matches without quotation marks, you can use something like

    var re = /"[^"]+"|\w+/g;
    var result = [];
    var match;
    while(match = re.exec(input))
        result.push(match[0].replace(/"/g, ""));
    

    If you don’t have to remove the quotation marks, you can just use

    var result = input.match(re);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data structure that represents C# code like this: class Namespace: string
I have a string variable that represents the name of a custom class. Example:
I have an instance of System.Type that represents an interface, and I want to
Consider the class below that represents a Broker: public class Broker { public string
I have a program that's creating a secure directory for user output. This is
I have a viewmodel that implements IDataError. In the viewmodel I have an ObservableCollection.
There seem to be a few virtual folders which have GUIDs associated to them
I've got an RDL report that is a roster -- it's a grid: each
I'm writing a converter between some dialects of the same programming language. I've found

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.