Solved

Regular Expression - Urgent

Posted on 2007-04-04
3
204 Views
Last Modified: 2010-03-31
Hi Experts ..

could you please give me an example of a regular expression that if I apply on a text there will be overlap between the matches parts??
e.g: return  the first index and last index of occurrences of "aba" in "ababa", so the result will be (0,3),(2,5). so it is overlaped.
0
Comment
Question by:DrAske
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
ID: 18855920
String RE = "(aba)";

Use a while loop for the Matcher
0
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 200 total points
ID: 18855961
Hope this was what you were lookinh for :

        Matcher match = Pattern.compile("aba").matcher("ababa");
        match.find();
        System.out.println("First Find : " + match.start()); // Prints 0
        match.find(match.start() + 1); // Starts the search from index 1
        System.out.println("Second Find : " + match.start()); // Prints 2
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18860542
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 74
CSV file parsing thru Java 13 51
Is there a simpler dropbox system? 10 51
Netbeans and org.apache.commons.lang3 issue 3 51
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question