Bug 14822 - match() analogue for regexes, eg firstgrep() or match( , regex=TRUE)
Summary: match() analogue for regexes, eg firstgrep() or match( , regex=TRUE)
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R 2.13.2
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2012-02-22 02:37 UTC by Mark Bravington
Modified: 2012-02-22 02:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Bravington 2012-02-22 02:37:57 UTC
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.