I have three lists:
> LIST 1 is a set of substrings that need to be removed from the main list - LIST 2. The substrings are either a prefix or a suffix (either the beginning or end of one of the strings in LIST 2).
" King Kangaroo"
" bush Bee"
"Newt "
"Hare "
"Otto Owl "
LIST 2
He was surprised when suddenly a King Kangaroo
And sitting astride a twig of a bush Bee
Hare has lost his spectacles
Otto Owl loved to rest quietly whilst no one was watching.
Newt knew too much to be stopped by so small a problem
LIST 3
He was surprised when suddenly a
And sitting astride a twig of a bush
has lost his spectacles
loved to rest quietly whilst no one was watching.
knew too much to be stopped by so small a problem
> LIST 1 is a set of substrings that need to be removed from the main list - LIST 2. The substrings are either a prefix or a suffix (either the beginning or end of one of the strings in LIST 2).
> LIST 2, as mentioned, is the main list that needs to have one of the prefixes/suffixes shown in LIST 1 removed.
> LIST 3 is the result that I am seeking
In other words, for each string in LIST 2, I need to go through LIST 1, and when a LIST 1 substring is contained in the LIST 2 string, then remove that substring. LIST 2 strings generally have one LIST 1 substring, but will not have more than 1 substring.
The larger problem this is part of makes me be especially interested in finding the simplest, most seamless solution. I very much appreciate any suggestions you can please share.
Thanks, Sven
LIST 1> LIST 3 is the result that I am seeking
In other words, for each string in LIST 2, I need to go through LIST 1, and when a LIST 1 substring is contained in the LIST 2 string, then remove that substring. LIST 2 strings generally have one LIST 1 substring, but will not have more than 1 substring.
The larger problem this is part of makes me be especially interested in finding the simplest, most seamless solution. I very much appreciate any suggestions you can please share.
Thanks, Sven
" King Kangaroo"
" bush Bee"
"Newt "
"Hare "
"Otto Owl "
LIST 2
He was surprised when suddenly a King Kangaroo
And sitting astride a twig of a bush Bee
Hare has lost his spectacles
Otto Owl loved to rest quietly whilst no one was watching.
Newt knew too much to be stopped by so small a problem
LIST 3
He was surprised when suddenly a
And sitting astride a twig of a bush
has lost his spectacles
loved to rest quietly whilst no one was watching.
knew too much to be stopped by so small a problem