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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:33:43+00:00 2026-05-13T21:33:43+00:00

I have a string that is similar to a path, but I have tried

  • 0

I have a string that is similar to a path, but I have tried some regex patterns that are supposed to parse paths and they don’t quite work.

Here’s the string

f|MyApparel/Templates/Events/

I need the “name parts” between the slashes.

I tried (\w+) but the array came back [0] = "f" and [1] = "f".

I tested the pattern on http://www.gskinner.com/RegExr/ and it seems to work correctly.

Here’s the AS code:

var pattern : RegExp = /(\w+)/g;
var hierarchy : Array = pattern.exec(params.category_id);
params.name = hierarchy.pop() as String;
  • 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-13T21:33:43+00:00Added an answer on May 13, 2026 at 9:33 pm

    pattern.exec() works like in JavaScript. It resets the lastIndex property every time it finds a match for a global regex, and next time you run it it starts from there.

    So it does not return an array of all matches, but only the very next match in the string. Hence you must run it in a loop until it returns null:

    var myPattern:RegExp = /(\w+)/g;  
    var str:String = "f|MyApparel/Templates/Events/";
    
    var result:Object = myPattern.exec(str);
    while (result != null) {
      trace( result.index, "\t", result);
      result = myPattern.exec(str);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, say I have a string to parse with a given format that maps
Ok I've tried searching this site for other similar questions, but those that come
There are some other questions on here that are similar but sufficiently different that
I have a string that contains something like this: ##### abc 'foo' /path/to/filename:1 #####
This is a similar question to those that have been asked before, but still
I have string that look like Array that fetched from other webservice like this
I have string that displays UTF-8 encoded characters, and I want to convert it
I have a String that holds the string representation of a byte value. String
I have a string that contains HTML image elements that is stored in a
I have a String that looks like this String = Förpackning Flaska (375 ml)

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.