Solved

Regular Expression - Urgent

Posted on 2007-04-04
3
199 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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

761 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