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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:10:25+00:00 2026-05-26T19:10:25+00:00

Having this Pattern for a regular expression : Pattern p = Pattern.compile([^\\.](?s)executeRule\\(\\s*?(.+?),\\s*?(‘.+?’),\\s*(\\[.+?\\]\\s*\\);)); I have

  • 0

Having this Pattern for a regular expression :

Pattern p = Pattern.compile("[^\\.](?s)executeRule\\(\\s*?(.+?),\\s*?('.+?'),\\s*(\\[.+?\\]\\s*\\);)");

I have a text like :

setSomething(false);
executeRule(document, 'PublishDocumentsToEmail', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
);

System.out.println("bla");

executeRule(document, 'PublishDocumentsToJMS', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
);

I want to find the sequences that contain the executeRule pattern.
My regular expression successfully finds only the first pattern occurence; all the patterns that follow after this first pattern will contain the previous patterns.

E.g. the first time I parse I find

executeRule(document, 'PublishDocumentsToEmail', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
);

I do some replacements on the pattern so it becomes

executeRule(document, 'PublishDocumentsToEmail', [
        'xmlMapping':'xmlmapping.TagRegLike',
        'emailAddress':'EMAIL(mymail@mail.com)',
        'emailSubject':'Test',
        'emailText':'test',
        'filenameSuffix':'test']
         ,crs
    );

After this I recursively call the same parsing method with the new text which is

setSomething(false);
executeRule(document, 'PublishDocumentsToEmail', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
    ,crs
);

System.out.println("bla");

executeRule(document, 'PublishDocumentsToJMS', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
);

and my regexp will match the entire section from

executeRule(document, 'PublishDocumentsToEmail', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
    ,crs
);

System.out.println("bla");

executeRule(document, 'PublishDocumentsToJMS', [
    'xmlMapping':'xmlmapping.TagRegLike',
    'emailAddress':'EMAIL(mymail@mail.com)',
    'emailSubject':'Test',
    'emailText':'test',
    'filenameSuffix':'test']
);

How can I get it to match only my second pattern ?

Thx

  • 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-26T19:10:26+00:00Added an answer on May 26, 2026 at 7:10 pm

    I didn’t thoroughly read your examples but you could either use \G in your pattern to start after the last match or just loop over the matches when using Matcher#find().

    Hope that helps.

    Update:

    After this I recursively call the same parsing method with the new text which is …

    Why would you call that recursively? I don’t see any recursion so you might just iterate over the matches you found in the first call.

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

Sidebar

Related Questions

I'm having trouble with an Expect regular expression. I'm trying to match on this
I'm having a lot of trouble writing this regular expression: (?<=\s+|^\s*|\(\s*|\.)(?:item|item1|item2)(?=\s+|\s*$|\s*\)|\.) It works very
I'm having to parse a text dump of a spreadsheet. I have a regular
I have just coded the below regular expression. I have a mini rich text
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
I am having problems trying to use the regular expression that I used in
I' using the MVVM pattern to build an application. In this application I have
I've been having this design-pattern problem for weeks. Where do I put the logic
I'm having problems creating a regular expression which will fix a valid string. The
So I'm having this code that processes what the client sends on a pattern.

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.