Solved

Regular Expression - Urgent

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

707 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