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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:06:42+00:00 2026-06-17T08:06:42+00:00

I have JS file and I need to parse that array in it: something:

  • 0

I have JS file and I need to parse that array in it:

something: ['Prefix.All','Ignore.Me','Prefix.Another']

I need to get all elements from “something” array with defined prefix.
Now I can get it, if array will contain only one element. My regexp:

String: something: ['Prefix.All']
Can get element with:
/something\s*:\s*\[['"](Prefix[a-zA-Z0-9.]+)['"]]/

But how to find many elements in array? And how to find more than one “something” array in file?

  • 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-17T08:06:43+00:00Added an answer on June 17, 2026 at 8:06 am

    In PHP you need to do it in two steps (which is probably better anyway – cramming everything into a single regex isn’t always the best idea).

    First, match the array you’re looking for. Note that this regex requires that there are no brackets between the delimiters [ and ], so nested arrays or strings that contain brackets will cause the regex to fail (as in “match the wrong text”):

    if (preg_match('/\bsomething: \[([^[\]]*)\]/', $subject, $regs)) {
        $result = $regs[1];
    }
    

    This will find the first occurrence of a string like something: ['Prefix.All','Ignore.Me','Prefix.Another'] and put 'Prefix.All','Ignore.Me','Prefix.Another' into $result.

    Then you can get all the matches from that:

    preg_match_all('/\bPrefix[^\']*/', $result, $final, PREG_PATTERN_ORDER);
    $final = $final[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that I need to parse into an array but I
I have a 100Mb file with roughly 10million lines that I need to parse
I have lines in an ASCII text file that I need to parse. The
I have an XML file which I need to parse using PHP and send
I have this tag into my html file: {{block:my_test_block}} {{news:my_test_block2}} I need to parse
I have js file where i need to call the function defined in the
I need to populate a json file, now I have something like this: {element:{id:10,quantity:1}}
I have an XML File with Elements that look like the following: <level> <name>Name
I have 2 questions: 1-I need to parse XML file and insert the data
I have some code that I parse and extract some matrices from. Theses matrices

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.