1

I am trying to find out what is this regular expression [[:space:][:digit:]]+ stands for.

I learn from Wikipedia that [:space:] means Whitespace characters and [:digit:] means Digits from 0 to 9.

So I think [[:space:][:digit:]]+ matches any Whitespace characters followed by a digit like ' 1' or ' 9'.

But, when I try this in r:

> txt <- c("arm","foot","lefroo", "laura ")
> i <- grep("[[:space:][:digit:]]+", txt)
> txt[i]
[1] "laura "

there is no digit in "laura ", but it sill matched.

this really confused me, any one can explain this?

freefrog
  • 523
  • 1
  • 5
  • 11

0 Answers0