Re: Deleting substrings
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Wed, 28 Jun 2006 21:51:50 +0000
Ravi said:
A function which takes a string and a substring as input and which
deletes the substring in the main string.
Eg: mainstr=abcxyghixy sub=xy
Result should be mainstr=abcghi.
Will it require recursion ?
No. You can use iteration.
How to handle the deletion part..I mean deleting a substring and then
starting all over again looking for the next substring.
Find the xy substring:
abcxyghixywhowantsxytosearchxyforever
^
Remove it:
abcghixywhowantsxytosearchxyforever
^
Starting at that point, find the next xy substring:
abcghixywhowantsxytosearchxyforever
^
Remove it:
abcghiwhowantsxytosearchxyforever
^
Starting at that point, find the next xy substring:
abcghiwhowantsxytosearchxyforever
^
Remove it:
abcghiwhowantstosearchxyforever
^
Starting at that point, find the next xy substring:
abcghiwhowantstosearchxyforever
^
Remove it:
abcghiwhowantstosearchforever
^
Starting at that point, find the next xy substring, oh, there isn't one, I
guess we're done here.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.
- References:
- Deleting substrings
- From: Ravi
- Deleting substrings
- Prev by Date: Re: ls lacking a feature?
- Next by Date: Re: ls lacking a feature?
- Previous by thread: Deleting substrings
- Next by thread: Re: Deleting substrings
- Index(es):
Relevant Pages
|