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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:40:44+00:00 2026-05-23T11:40:44+00:00

I have a HTML input that have three patterns like this: Pattern one </div>

  • 0

I have a HTML input that have three patterns like this:

Pattern one

</div>

<div class="myclass">

Pattern two

</div>

    <p class="ProductMeta">29-06-2011</p>

<div class="myclass">

Pattern trhee

</div>

    <p class="ProductMeta">29/06/2011</p>

<div class="myclass">

I’m trying to create a RegEx that can catch the tree dates: empty, with dashes and with slashes. I think i need some kind of nested groups, but can’t make it work.

This is the RegEx I’ve created:

Regex r = new Regex(
                @"src=""</div>\s+<p class=""ProductMeta"">([\d\/\-]+)"
                , RegexOptions.Compiled | RegexOptions.IgnoreCase);

And tried the following to make the group optional:

Regex r = new Regex(
                    @"src=""</div>[\s+<p class=""ProductMeta"">([\d\/\-]+)]?"
                    , RegexOptions.Compiled | RegexOptions.IgnoreCase);

Can anyone help me?

The console test does the following to print on screen:

foreach (Match m in mcl)
            {
                Console.WriteLine(m.Groups[1].Value.Replace("-","/") + " - " + m.Groups[5].Value);
            }

            Console.Read();

Thanks.

  • 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-23T11:40:44+00:00Added an answer on May 23, 2026 at 11:40 am

    You can’t make the []‘s an optional group. Only () can be optional.

    var test1 = 
    @"</div>
    <div class=""myclass"">";
    
    var test2 =
    @"</div>
        <p class=""ProductMeta"">29-06-2011</p>
    <div class=""myclass"">";
    
    var test3 = 
    @"</div>
        <p class=""ProductMeta"">29/06/2011</p>
    <div class=""myclass"">";
    
    string re = @"</div>\s+(<p class=""ProductMeta"">(\d\d([-/])\d\d\3\d\d\d\d))?";
    Regex regExpr = new Regex(re, RegexOptions.Multiline);
    
    Console.WriteLine(regExpr.Match(test1).Groups[2].Value); //== ""
    Console.WriteLine(regExpr.Match(test2).Groups[2].Value); //== "29-06-2011" 
    Console.WriteLine(regExpr.Match(test3).Groups[2].Value); //== "29/06/2011"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my HTML code, I have a form tag that contains two input boxes,
I have a three pieces of code that are giving me trouble. This one
I have a simple form with some plain html input like bellow using ASP.NET
I have a html element (like select box input field) in a table. Now
I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input
I have a page that has three divs one at the top, one at
I have a view model that has a property that looks like this Property
I have this form in HTML: <form action=# method=post> <label for=label-id>id</label> <input type=text name=id
I'm trying to have three input that display a list of lodging that march
I have some buttons below in my HTML: <p> <input class=answerBtns name=answer type=button value=A

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.