Reputation: 13
I have readLines from txt file.
Some line instances in text file are:
EAR99
EA
EAR99. NLR
EAFH9
Order Manag
There are more than 800 lines.
How could I find out line number which are starting with "EA***" (EA with three more alphanumeric character) substring. Thus in my example I should get line number:- 1,3,4. Line 2 is not qualified as it is on "EA".
Upvotes: 1
Views: 41
Reputation: 887571
We can use grep
grep("^EA[[:alnum:]]{3}", lines)
#[1] 1 3 4
lines <- readLines(textConnection("EAR99
EA
EAR99. NLR
EAFH9
Order Manag"))
Upvotes: 2