Hi all
Got a problem i thought would be fairly easy to figure out :\!
I've got a large string, say of 2000 characters. And a keyword phrase.
What I'd like to do is find the first instance of this keyword phrase in the string, then chop the string to take 50 characters from behind the first instance and 50 characters from infront.
heres a small example scaled down.
string: hello my name is andy
keyword: name
result: my name is
Ideas:
I've thought of splitting the string into an array, then i can loop through this array until i find the phrase and simply take combine the previous 49 array entries and the next 49 to make a new string.
This is my only idea so far and I'm put off by it as it has memory issues - big strings = even bigger arrays!!
any advice is appreciated
andy
Got a problem i thought would be fairly easy to figure out :\!
I've got a large string, say of 2000 characters. And a keyword phrase.
What I'd like to do is find the first instance of this keyword phrase in the string, then chop the string to take 50 characters from behind the first instance and 50 characters from infront.
heres a small example scaled down.
string: hello my name is andy
keyword: name
result: my name is
Ideas:
I've thought of splitting the string into an array, then i can loop through this array until i find the phrase and simply take combine the previous 49 array entries and the next 49 to make a new string.
This is my only idea so far and I'm put off by it as it has memory issues - big strings = even bigger arrays!!
any advice is appreciated
andy