It would be a great speeder-upper to have something like grep() that only returns the first match (if there is one). If it could work like match() and take a vector of regexes as its pattern argument, and return the first-matching-position for each, that'd be even nicer. The point is to avoid wasting cycles when only the first match is required.
R's regex and text-manipulation facilities are very good these days; eg I find it very useful for automatically manipulating low-level programming code. Often I only need the first line that greps to some pattern, but grep() etc look thru the entire object.
It would be a great speeder-upper to have something like grep() that only returns the first match (if there is one). If it could work like match() and take a vector of regexes as its pattern argument, and return the first-matching-position for each, that'd be even nicer. The point is to avoid wasting cycles when only the first match is required.
R's regex and text-manipulation facilities are very good these days; eg I find it very useful for automatically manipulating low-level programming code. Often I only need the first line that greps to some pattern, but grep() etc look thru the entire object.
METADATA