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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:18:14+00:00 2026-05-11T14:18:14+00:00

For example, given the string 2009/11/12 I want to get the regex (\d{2}/d{2}/d{4}), so

  • 0

For example, given the string ‘2009/11/12’ I want to get the regex (‘\d{2}/d{2}/d{4}’), so I’ll be able to match ‘2001/01/02’ too.

Is there something that does that? Something similar? Any idea’ as to how to do it?

  • 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. 2026-05-11T14:18:14+00:00Added an answer on May 11, 2026 at 2:18 pm

    There is text2re, a free web-based ‘regex by example’ generator.

    I don’t think this is available in source code, though. I dare to say there is no automatic regex generator that gets it right without user intervention, since this would require the machine knowing what you want.


    Note that text2re uses a template-based, modularized and very generalized approach to regular expression generation. The expressions it generates work, but they are much more complex than the equivalent hand-crafted expression. It is not a good tool to learn regular expressions because it does a pretty lousy job at setting examples.

    For instance, the string '2009/11/12' would be recognized as a yyyymmdd pattern, which is helpful. The tool transforms it into this 125 character monster:

    ((?:(?:[1]{1}\d{1}\d{1}\d{1})|(?:[2]{1}\d{3}))[-:\/.](?:[0]?[1-9]|[1][012])[-:\/.](?:(?:[0-2]?\d{1})|(?:[3][01]{1})))(?![\d]) 

    The hand-made equivalent would take up merely two fifths of that (50 characters):

    ([12]\d{3})[-:/.](0?\d|1[0-2])[-:/.]([0-2]?\d|3[01])\b 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FOR EXAMPLE: Given a string... 1,2,3,4 I need to be able to remove a
Given the following simple example: List<string> list = new List<string>() { One, Two, Three,
I need to highlight, case insensitively, given keywords in a JavaScript string. For example:
For example, given a type param method i'm looking for something like the part
I want to select blocks of text within given string. These blocks of text
I want to replace a string with given string by specifying starting and ending
Given this example: <img class=a /> <img /> <img class=a /> <img class=a id=active
Given an example of calling two web services methods from a session bean, what
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using

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.