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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:49:55+00:00 2026-05-26T18:49:55+00:00

I receive PatternSyntaxException when try to compile the following regex: bd.matches((a)?b(?(1)c|d)) this regex matches

  • 0

I receive PatternSyntaxException when try to compile the following regex:

"bd".matches("(a)?b(?(1)c|d)")

this regex matches bd and abc. It does not match bc.

any ideas? thanks.

ok i need to write regex to match next 4 strings:

*date date* date date1*date2

should not match:

*date* date1*date2* *date1*date2 date** ...

but this should be done with single matching, not several.

please do not post answer like:

(date*date)|(*date)|(date*)|(date)
  • 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-26T18:49:56+00:00Added an answer on May 26, 2026 at 6:49 pm

    Adding a new answer based on the OP’s edit and samples:

    ok i need to write regex to match next 4 strings:
    *date date* date date1*date2
    should not match:
    *date* date1*date2* *date1*date2 date** ...

    If I think I understand you, you could use a regex based on Alan Moore pseudo conditional trick.

    Something like this ^(?:[*]())?date(?:(?!\1)[*](?:date)?|)$ might work.
    I am asuming ‘date’ is the only text in the samples, and each group of non-space characters in the samples are distinct lines of text.

    In your text that passes, there is only one form that requires a pseudo conditional. That is ‘date*date’. So, I’ve included a Perl sample below (since I don’t have a Java compiler) that expands the regex for clarity.

    use strict;
    use warnings;
    
    my @samps = qw(
    
    *date
     date*
     date
     date*date
    *date*
     date*date*
    *date*date
     date**
    );
    
    for my $str (@samps)
    {
       print "\n'$str'\n";
    
       if ($str =~
           /
            ^          # Begin of string
            (?:             # Expr grouping
                [*]()          # Asterisk found then DEFINE capture group 1 as empty string
            )?              # End expr group, optional, if asterisk NOT found, capture group 1 stays UNDEFined
            date   #  'data'
            (?:             # Expr grouping
                (?!\1)           # Pseudo conditional: If no asterisk (group 1 is UNDEF), then
                [*](?:date)?     # look for '*' folowed by optional 'data'
              |               # OR,
            )                    # Asterisk or not, should be nothing here
            $          # End of string
          /x)
    
         {
             print "matched: '$str'\n";
         }
    }
    

    Output:

    '*date'
    matched: '*date'
    
    'date*'
    matched: 'date*'
    
    'date'
    matched: 'date'
    
    'date*date'
    matched: 'date*date'
    
    '*date*'
    
    'date*date*'
    
    '*date*date'
    
    'date**'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I receive this Run-Time Check Failure upon the return in the following code. I
I receive this message (see image below) when I try to edit in debugging.
I receive this error when I try to run the maven goal - mvn
I receive a date-time from automation system like this: 00:00:30:00 . When I try
Receive activities in WF4 can take two kind of values, Message or Parameters. Does
I receive encoded PDF files regularly. The encoding works like this: the PDFs can
I receive a JSON response in an Ajax request from the server. This way
I receive ads in the following code. When the ad is Google Sense ,
I receive this error when trying to run the client. The type 'StringPro.IMyString' is
We receive this error quite frequently from our appengine application. Are other people receiving

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.