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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:41:12+00:00 2026-06-01T00:41:12+00:00

I have the string SUM([A2:A10],[B2:B10],[C2:C10],[D2:D10]) and I need to get the elements [A2:A10],[B2:B10],[C2:C10],[D2:D10] in

  • 0

I have the string SUM([A2:A10],[B2:B10],[C2:C10],[D2:D10]) and I need to get the elements [A2:A10],[B2:B10],[C2:C10],[D2:D10] in an array, so I used match() in js. The code snippet is

var formula = "SUM([A2:A10],[B2:B10],[C2:C10],[D2:D10])";
var reg = /\[(a-zA-Z0-9)+\]/;
matches = formula.match(reg);

But I am not getting the match. I hope the regular expression is wrong. I am very poor in building regular expression. What will be the correct regular expression?

  • 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-06-01T00:41:13+00:00Added an answer on June 1, 2026 at 12:41 am

    Try it like this:

    var formula = 'SUM([A2:A10],[B2:B10],[C2:C10],[D2:D10])';
    var reg = /\[\w+:\w+\]/g;
    matches = formula.match(reg);
    

    Output:

    ["[A2:A10]", "[B2:B10]", "[C2:C10]", "[D2:D10]"]
    

    Your regex was in the right direction, but didn’t include the colon and captured individual characters. The \w escape sequence I used is a shortcut for a word character ([a-zA-Z0-9_]), makes it more readable. The g flag is necessary to get all matches instead of just the first one.

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

Sidebar

Related Questions

I have following Java code: String s2 = SUM 12 32 42; Pattern pat1
I have a dictionary of (string, decimal) and need to calculate the sum of
I have this code which calculates the sum of "letter numbers" in a string,
I have string that I want to chop to array of substrings of given
I have a string in the format: MyList.Where(abc).GroupBy(def).Sum(ghi) The Where & GroupBy parts are
I have a string array or arraylist that is passed to my program in
I have an array with times (string) e.g 2:23, 3:2:22 etc. $times = array(2:33,
I have this query string... select i.invoiceid, i.date, i.total, i.total - (select ifnull(sum(p.amount), 0)
I am trying to select all elements on the page which have the string
Lately I often have to read Java code like this: LinkedHashMap<String, Integer> totals =

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.