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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:54:33+00:00 2026-06-15T20:54:33+00:00

Im using preg_match_all to check dates and words that starts with capital, the problem

  • 0

Im using preg_match_all to check dates and words that starts with capital, the problem is on the dates because on the regex tester its telling me that this regex is fine but in the php script its not doing it correctly, my pattern is this:

$pattern = "#(((0[1-9]|[12][0-9]|3[01])([\/\.\\\-])((0[1-9]|1[012])\11)?)(\d\d\d\d|\d\d))+|([A-Z][a-z]+)(\s[A-Z][a-z]+)*#";

and I want it to match this: “12.10.1990” as well as “12.10.90”

thanks for your help!

  • 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-15T20:54:34+00:00Added an answer on June 15, 2026 at 8:54 pm
    $string = '12.10.1990 as well as 12.10.90';
    
    preg_match_all('/[01]\d\.[0-3]\d\.\d{2,4}/', $string, $match);
    
    print_r($match);
    

    Use this pattern for the date matching portion of your regex. Regardless you are trying to re-invent the wheel. There are built in PHP functions that can help you better determine if a date is valid or not.

    • http://php.net/manual/en/function.checkdate.php

    Use explode() and then put each segment into this function for example:

    $string = '12.10.1990';
    //$string = '12.10.90';
    
    $string = explode('.', $string);
    var_dump(checkdate($string[0], $string[1], $string[2]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with regex, using preg_match_all(), to match something of a variable
I'm using this function: preg_match_all('/((\d{9})\.html)/s', $content, $results); It works fine but i just want
I am using this IP Validation Function that I came across while browsing, it
I am looking for a regular expression using preg_match_all in PHP 5 that would
Using preg_match_all(), I want to match something like: ...randomtext...>MATCH1</a> (MATCH2)...randomtext... EDIT: to clarify, this
I'm using preg_match_all for very long pattern. when run the code, i got this
I am using preg_match_all to pull phone numbers from a thread. This puts them
I am using preg_match_all in php to check the characters in the username and
I'm using preg_match_all function to grab details on a web page. But problem is
i'm using preg_match_all('/<?(.*)?>/', $bigString, $matches, PREG_OFFSET_CAPTURE); to find the contents of everything between <?

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.