A
ag07
Guest
How can I search a string for several substrings?
Ideally, it would search the main string for all substrings simultaneously, and return thhe results as a string of numbers, like this:
Main string:
Fruit = "apple berry berry orange berry cherry banana apple pineapple grape peach melon pineapple apricot blueberry";
substrings to search for: "berry pineapple apple"
Result: 3 2 2
(3 x "berry", 2 x "pineapple", 2 x "apple")
If it doesn't work to search at the same time, whats the best way to search sequentially?
eg, first search for "berry", then "pineapple", finally "apple"
Can this be done with strings, or should I use lists?
thank you
Ideally, it would search the main string for all substrings simultaneously, and return thhe results as a string of numbers, like this:
Main string:
Fruit = "apple berry berry orange berry cherry banana apple pineapple grape peach melon pineapple apricot blueberry";
substrings to search for: "berry pineapple apple"
Result: 3 2 2
(3 x "berry", 2 x "pineapple", 2 x "apple")
If it doesn't work to search at the same time, whats the best way to search sequentially?
eg, first search for "berry", then "pineapple", finally "apple"
Can this be done with strings, or should I use lists?
thank you