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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:04:10+00:00 2026-06-01T13:04:10+00:00

A regex answers a yes or no question – does the string match the

  • 0

A regex answers a yes or no question – does the string match the pattern.

I want to separate the no’s into two categories:

  • invalid strings that are prefixes of valid strings
  • invalid strings that are not prefixes of valid

Here’s an example (regular expression 01+2):

  • 012 is valid

  • 12 is invalid; it is not a prefix of a valid string

  • 01 is invalid; it is a prefix of a valid string: 012

Java can do this.

Can re do this? If not, is there a library that can make this distinction?

  • 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-01T13:04:11+00:00Added an answer on June 1, 2026 at 1:04 pm

    I second the recommendation of regex. The module is simply fantastic.

    Here’s an example of fuzzy matching with regex:

    import regex
    
    # traditional matching - three digits
    r = '(?:\d\d\d)'
    print regex.findall(r, '1xx22yy333zz')
    ## ['333']
    
    # fuzzy matching - three digits, allow at most 2 deletions
    r = '(?:\d\d\d){d<3}'
    print regex.findall(r, '1xx22yy333zz')
    ## ['1', '22', '333']
    

    The {d<3} part basically says “if we add one or two chars to that, that would be a match” – the same as point 3. in your question.

    See http://pypi.python.org/pypi/regex for more info (look for ‘Approximate “fuzzy” matching’).

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

Sidebar

Related Questions

What regex pattern would need I to pass to java.lang.String.split() to split a String
Simple regex question. I have a string on the following format: this is a
While the question check if input is type of string has been closed two
yes it's another .net regex question :) (please excuse the long waffle leading up
This is a followup to this question The first two answers are both correct
I am using c# regex.replace and I want to replace this string: test =
This should be a pretty simple regex question but I couldn't find any answers
I am looking for a regex that will match a string that starts with
My regex pattern looks something like <xxxx location=file path/level1/level2 xxxx some=xxx> I am only
Another RegEx question for a search I'm trying to do. The Problem : Determine

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.