Understanding the syntax of the "sep" argument default in tidyr's separate() function

1.1k views Asked by At

I was reading through the documentation of the separate() function in the tidyr package, and I don't fully understand the default for the sep argument.

According to the documentation, the default is sep = "[^[:alnum:]]+", which means that "[t]he default value is a regular expression that matches any sequence of non-alphanumeric values." I interpreted this to mean that the separator would be "any character or substring of characters that is not/does not contain a letter or a number". If this is inaccurate, please let me know.

What I don't understand is how the shorthand for alphanumeric [:alnum:] became inverted with a caret, another set of brackets, and a plus sign. The website to which I just linked partly explains this confusion (namely the [^[]] part), but it didn't seem to be talking about R. Is this standard syntax for R? Is this co-opted from a different language?

I am new both to programming and to R, so I could just have not encountered this kind of syntax before.

0

There are 0 answers