1

I have a file that contains a specific line that begins with "***" How can I find the line with this string since it begins with wild cards?

I would normally use

Line_n <- grep("*** The Maximum 1hour", readLines(con=filename))

Thanks!

melmo
  • 757
  • 3
  • 15

1 Answers1

0
s <- c("** The Maximum 1hour", "*** The Maximum 1hour", 
       "*** The Maximum 2hours", "The Maximum 1hour", 
       "*** The Maximum 1hour", "+++ The Maximum 1hour",
       "dummy *** The Maximum 1hour")

grep("^[*]{3} The Maximum 1hour", s)
[1] 2 5

finds strings with exactly 3 asterisks at the beginning of the string (but only then).

Jan
  • 4,974
  • 3
  • 26
  • 43