Solved

Regular Expression - Urgent

Posted on 2007-04-04
3
169 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
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
Comment Utility
String RE = "(aba)";

Use a while loop for the Matcher
0
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 200 total points
Comment Utility
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
Comment Utility
:-)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Return ZipOutputStream using Servlet 2 32
mergeTwo  challenge 13 71
Receive file in Servlet 1 36
Updating Java 9 87
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now