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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:40:43+00:00 2026-05-27T12:40:43+00:00

I have a field with wiki style rendering on it that I’d like to

  • 0

I have a field with wiki style rendering on it that I’d like to bust up in Javascript.

The text I’m trying to parse looks like this:

{color:#47B}_name1_{color}
{color:#555}description1{color} 
---
{color:#47B}_name2_{color}
{color:#555}description2{color} 
---
{color:#47B}_name3_{color}
{color:#555}description3{color} 
---
etc

Where name1 and description1 belong together, name2 and description2 belong together, and so forth. The values for name and description are user supplied values, with description potentially spanning multiple lines.

My end goal is to be able to extract the values of each name and each description from the text (and be able to reliably associated name1 with description1, etc).

My question is: If I used a regex to match all the names into an array and all the descriptions into an array, can I be ensured that the items in the array are in the correct order? That is, will names[0] always be the first name in the parsed text (assuming I did a javascript regex match into the names array)? Also- is this bad practice/should I do this another way?

The regular expression I’m trying to use to match names is:

/^(\{color\:#47B\})(_)(\s*?)(.*?)(\s*?)(_)(\{color\})$/

And the regular expression I’m using to match descriptions is:

/(\{color\:#555\})(.*?)(\{color\})/

  • 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-27T12:40:43+00:00Added an answer on May 27, 2026 at 12:40 pm

    A regex search will always return matches in source order (i.e. in the order in which they occur in the source text.)

    I assume you are asking this question because you’re hoping to do two regex matches (one for name, one for description) and then get two result arrays, and guarantee that namesmatch[i] always goes with descriptionmatch[i]. However, this will only be true if your source text is always exactly perfect.

    In this case it may be better or safer either to use a single regex that matches both at once, or split your source up by those -- delimiters and then match within each block. The reason why it may be safer is that your source text may contain errors, and at least in this case you can detect that and have as much good data as possible.

    A note about your regexes. The . does not match newlines, so if the text between your {color} braces might have a newline you need to include newlines explicitly. [\s\S] and [^] are common idioms for this. Alternatively, if all . in a regex should match newlines, set the dotAll flag (s).

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

Sidebar

Related Questions

I have field like a_b_c_d I want as the output a b c_d, this
I have field X that contains text with spaces in the end of the
I have one field that I need to sum lets say named items However
I have a field in a database that is nearly unique: 98% of the
I have a field in my form labeled Name that will contain both the
I have a field in my report that needs to have a length of
UPDATE: It was suggested in the comments that I create a wiki for this.
I am trying to read a binary file and parse the bytes I have
I am storing user inputs through a form with wiki style formatting ( text
I have a count field in a table that I need to increment and

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.