0

This seems like a basic question but I couldn't figure it out after spending a good part of the morning researching.

I want to understand why using stringr::str_match() in R

NP_[0-9][.0-9]+ or NP_[0-9]+[.0-9]{2}

and not NP_[0-9]+[.0-9] or NP_[0-9]+[.0-9]{1}

matches NP_848713.1 in

string1<-c("It_is_burried_in_here_NP_848713.1_somewhere")

Thanks

Moritz
  • 289
  • 3
  • 12
  • 1
    See how these regex patterns work at [regex101.com](http://regex101.com). – Wiktor Stribiżew Sep 28 '16 at 12:52
  • @Wiktor Thanks for the input. Duhhh, It counts the `.`. Now I feel a little stupid. Thanks for the help! – Moritz Sep 28 '16 at 13:05
  • Well, the point is that `[.0-9]` matches 1 char and it is equal to `[.0-9]{1}` (the `{1}` is always redundant). – Wiktor Stribiżew Sep 28 '16 at 13:07
  • For some strange reason the `.` was not a character in my mind. A bad faux pas that send me spinning in all the wrong directions. Good on you to point out the redundancy of {1}. – Moritz Sep 28 '16 at 13:18

0 Answers0