tags:

views:

36

answers:

2

ex:
if we have a string s1="abcde" s2="abd"
find the occurrences of "ad" in s1,s2.. here the occurrence count is 2 on the whole..

Can any1 help me regarding the regex code in java... pls..

A: 

You could use indexOf(String str) and then indexOf(String str, int fromIndex) to find all the occurrences and their position.

Alberto Zaccagni
A: 

please have a look at knuth pratt morris algorithm for text search

Suresh S