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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:40:29+00:00 2026-05-25T19:40:29+00:00

I’m following up on a question since the question changed Finding the regex for

  • 0

I’m following up on a question since the question changed

Finding the regex for /<region>/<city>/<category>?

The answer that works is /(?:[^/]+)/?([^/]*)/?([^/]*) and it outputs city in $1, category in $2 but I also just want to output $0 so can you help me modify it a little do achieve this?

It seems I’ll finally be able to do what I want with this regex and it also applies to 2 earlier questions I asked

Can I use a python regex for letters, dashes and underscores?

How to represent geographical locations

My plan is to implement the functionality with multitenancy so that same software can serve large cities like sao paulo and delhi at same time with same code so I must make it very general and for all locations with same expression i.e. //

Plus the problem what we mean when we say e.g. “Search New York” – the region or the city? One piece of info for this is the output from google maps that defines “New York” where “region” corresponds to “administrative area”:

{
  "name": "New York",
  "Status": {
    "code": 200,
    "request": "geocode"
  },
  "Placemark": [ {
    "id": "p1",
    "address": "New York, NY, USA",
    "AddressDetails": {
   "Accuracy" : 4,
   "Country" : {
      "AdministrativeArea" : {
         "AdministrativeAreaName" : "NY",
         "SubAdministrativeArea" : {
            "Locality" : {
               "LocalityName" : "New York"
            },
            "SubAdministrativeAreaName" : "New York"
         }
      },
      "CountryName" : "USA",
      "CountryNameCode" : "US"
   }
},
    "ExtendedData": {
      "LatLonBox": {
        "north": 40.8495342,
        "south": 40.5788964,
        "east": -73.7498543,
        "west": -74.2620919
      }
    },
    "Point": {
      "coordinates": [ -74.0059731, 40.7143528, 0 ]
    }
  }, {
    "id": "p2",
    "address": "Manhattan, New York, NY, USA",
    "AddressDetails": {
   "Accuracy" : 4,
   "Country" : {
      "AdministrativeArea" : {
         "AdministrativeAreaName" : "NY",
         "SubAdministrativeArea" : {
            "Locality" : {
               "DependentLocality" : {
                  "DependentLocalityName" : "Manhattan"
               },
               "LocalityName" : "New York"
            },
            "SubAdministrativeAreaName" : "New York"
         }
      },
      "CountryName" : "USA",
      "CountryNameCode" : "US"
   }
},
    "ExtendedData": {
      "LatLonBox": {
        "north": 40.8200450,
        "south": 40.6980780,
        "east": -73.9033130,
        "west": -74.0351490
      }
    },
    "Point": {
      "coordinates": [ -73.9662495, 40.7834345, 0 ]
    }
  } ]
}
:

However I don’t think all the code has to be in the same file since I can make one file per region or some structure like that since the total number of regions (“states”) for the whole world is not very much larger than the total number of countries but the total number of cities of the world is a large number. And it seems to have a file for every country included in the project is an easy and good way to organize.

Many thanks

Update

The regex I found useful is

application = webapp.WSGIApplication([('/([^/]+)/?([^/]*)/?([^/]*)',Handler),],debug=True)

  • 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-25T19:40:30+00:00Added an answer on May 25, 2026 at 7:40 pm

    (?:…)
    A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses,
    but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.

    http://docs.python.org/library/re.html

    ?: is means, match it but doesn’t save it in groups, remove it and try again.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.