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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:22:01+00:00 2026-06-02T16:22:01+00:00

I want to find repeating patterns in the following sentence using reqular expressions in

  • 0

I want to find repeating patterns in the following sentence using reqular expressions in java:

username|s:5:"derick256";privilege|s:5:"derick542";premium|s:5:"derik542";

I need to extract the following, and potentially more, so I need a solution that is easily expandable…

  1. username derick256
  2. privilege derick 542
  3. premium derik542

This is my code…

String re1="((?:[a-z][a-z0-9_]*))"; // Variable Name 1
String re2=".*?";   // Non-greedy match on filler
String re3="(?:[a-z][a-z0-9_]*)";   // Uninteresting: var
String re4=".*?";   // Non-greedy match on filler
String re5="((?:[a-z][a-z0-9_]*))"; // Variable Name 2

Pattern p = Pattern.compile(re1+re2+re3+re4+re5,Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher m = p.matcher(strLine);
if (m.find()){
    String word1=m.group(1);
    String word2=m.group(2);
    System.out.print("("+word1.toString()+")"+"("+word2.toString()+")"+"\n");
}

But I only got username derick256. Could anyone please assist me to understand the error.

  • 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-02T16:22:02+00:00Added an answer on June 2, 2026 at 4:22 pm

    Change if(m.find()) to while(m.find()).

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

Sidebar

Related Questions

I want to find the RSA code in both Javascript and Java code. And
Let's say I want to find all sets of 5 single-digit, non-repeating numbers that
I want to find memory leaks in my application using standard utilities. Previously I
I find myself using the 'pattern' below rather unsettlingly often, when I want to
I frequently find myself using the following pattern for string formatting. a = 3
I want find all Saturdays and Sundays in A given month. How can I
I want to find the first item in a sorted vector that has a
I want to find which tables are related to a specific table. I can
I want to find out the time in unix time (ie seconds since the
I want to find the number of the week which a day belongs to

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.