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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:07:53+00:00 2026-06-15T22:07:53+00:00

I’m looking to create a regex for these patterns: [num] [am] [num] [pm] [num]

  • 0

I’m looking to create a regex for these patterns:

[num] [am]
[num] [pm]
[num] [-] [num]
[num] [:] [num]

with or w/o spaces

It’s to determine if there is a time in a sentence. Ideally, it would actually parse out the time. The sentences would be like:

“This event is at 9am at…”
“Blues, 5:30, pressroom..”
“Meet at 5pm!”
“All night 9-8 rockin’ it!”

My project is in .NET in case it’s relevant.

  • 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-15T22:07:54+00:00Added an answer on June 15, 2026 at 10:07 pm

    Given your definition, I think something like this is about as good as you can do:

    "\\b(1[012]|[1-9])(\\s?(am|pm)|:[0-5][0-9]|-(1[012]|[1-9]))\\b"
    

    This requires that an hour be between 1-12 and minutes be 0-59. It also requires word boundaries around the time. It doesn’t allow spaces around dashes or colons.

    Nevertheless, you are going to get a lot of false positives by definition, especially with your [num]-[num] format, which looks a lot like dates and other stuff.

    Tested here. I didn’t find a specific .NET tester, but I think it is all standard.

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

Sidebar

Related Questions

Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create something like in this image. Each block would have an
I am looking for a regex to create a string of characters with the
<a href=/search?hl=en&amp;pwst=1&amp;sa=X&amp;ei=RCPqTqkHycryA_bK_f0J&amp;ved=0CCUQvwUoAQ&amp;q=psychology&amp;spell=1 class=spell><b><i>psychology</i></b></a> Hi, I'm looking to create a regex which matches this anchor
I am looking to create a reg ex in JS that obtains 2 values
I looking to create a custom calender with Zend Framework, I am hoping that
I'm looking to create a portfolio using a Wordpress blog. On the summary page
I'm looking to create a command line menu in powershell, with the options coming
I'm looking to create a table in html to be used to insert the
I'm looking to create a read-only table, and MYSQL permissions, I think, are the

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.