in reply to words wich ends with "f"
You can try this:
#!/usr/bin/perl use strict; use warnings; $_="four fifth two frog left leaf fred wolf foul"; my @F=m/\bf\w*/g; print "@F\n"; @F=m/\w*f\b/g; print "@F\n"; @F=m/\w+f\w+/g; print "@F\n";
Results in:
four fifth frog fred foul leaf wolf fifth left
Update: the third case gives you all the words containing an "f" in the middle. To have all words containing but not beginning with an "f" use /[^f]\w*f\w*/g
Update #2: this is better /\b[^f\W]\w*f\w*/g
Careful with that hash Eugene.
|
|---|