Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regular Expression - Urgent

Posted on 2007-04-04
3
Medium Priority
?
217 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 1200 total points
ID: 18855920
String RE = "(aba)";

Use a while loop for the Matcher
0
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 800 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

636 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