Re: Deleting substrings
- From: Jon Harrop <usenet@xxxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 00:12:31 +0100
Ravi wrote:
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.
In OCaml:
# Str.global_replace (Str.regexp_string "xy") "" "abcxyghixy";;
- : string = "abcghi"
Will it require recursion ?
No, you could use iteration, continuation passing style, regexps, ...
How to handle the deletion part..I mean deleting a substring and then
starting all over again looking for the next substring.
If you must write it by hand then keep an index into the input string, skip
the substring when you encounter it or copy a character otherwise.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html
.
- 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: Re: Deleting substrings
- Next by thread: Re: Deleting substrings
- Index(es):
Relevant Pages
|