How to search for alphanumeric word before or after a keyword in perl?
- by aliocee
I have sentences as shown in the below examples:
$sen1 = "The quick brown fox jump KEYWORD over123 the3 lazy dog, fox is quick";
$sen2 = "The quick brown fox jump123 KEYWORD over the lazy dog, fox is quick";
i want to use the keyword 'KEYWORD' as my search string to extract the alphanumeric words before and after the search string using Perl regular expression.
sample output:
over123
jump123
NB: The word 'the3' is left out because i'm only searching for alphanumeric words exactly before or after the 'KEYWORD'.
Thanks