Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

occurence of substrings in another string

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
hallo,
i have to find the longest substring of one string into another string. The substrings must all start with the first character, like this:

String to be found: "ABDC", I have to find "A", "AB", "ABC", "ABCD"

String to be searched:
ACDBDDDBCAB

--> in this case the output should be "AB", because is the longest occurence.

Does anyone has a suggestion on how to proceed or have some code that does something similar? thanks for help
 
I know - it's just one of those funny things

answer a - some small number
answer b - some other small number
answwr c - some slightly bigger number
answer 4 - a number bigger than the other 3 by a factor of 30 !!

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Just pulling the creation of the RegExp object out of the loop makes answer 4 competitive with answer 3 in this example. And as the target string gets longer, answer 4 overtakes answer 3 ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top