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

  • Home
  • SEARCH
  • 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 4116724
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:44:39+00:00 2026-05-20T22:44:39+00:00

If I have a URL contstruct /SomePart/#/Group1/Group2 I need to return the group1 and/or

  • 0

If I have a URL contstruct

/SomePart/#/Group1/Group2

I need to return the group1 and/or group2, i.e. the url could be either
/SomePart/#/Group1
OR
/SomePart/#/Group1/Group2

The current regex I have only gets the first part, not sure how to extend to the latter.

SomePart\/\#\/([a-zA-Z0-9_-]+)
  • 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-20T22:44:40+00:00Added an answer on May 20, 2026 at 10:44 pm

    Do you need to use a regex? Often using a regular expression is overkill. A few lines of code will be faster, and more maintainable than a big regular expression.

    If your language has a split method just use that and check the last two items in the generated array.

    arr = url.split("/")
    if arr[len-2] == "#":
      # There is only one group, so return arr[len-1]
    else:
      # Return the last two elements of the array as Group1 and Group2
    

    This pseudo-code is probably a good starting place. In parting, an applicable quote:

    “Debugging is twice as hard as writing
    the code in the first place.
    Therefore, if you write the code as
    cleverly as possible, you are, by
    definition, not smart enough to debug
    it.” –Brian Kernighan

    Save your cleverness for something else 🙂

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

Sidebar

Related Questions

I have URL like this: http://localhost/PMApp/temp.htm?ProjectID=462 What I need to do is to get
I have URL like: http://example.com#something , how do I remove #something , without causing
I have URL scheme for my blog like this: http://www.example.com/%YEAR%/%MONTH%/%CATEGORY%/%POST_TITLE%/ Now i want to
I have url http://www.domain.com/folder/?variable=1 i would like to do a mod redirect to index.cfm
I currently have url like localhost/zend_practice/countries/index?data=1 where countries is the name of my controller
Is it possible in CakePHP to have URL aliases in routes.php? Or by what
My permalink structure is set so I have url.com/page I made a basic PHP
& is a reserved character in html therefore everywhere I have url's pointing to
I have a URL where I am passing in a keyword (http://www.example.com/store?keyword=google). I want
I have a url of a type where query string is like this... ?

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.