Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image Added

For this work with regular expressions, we will start with a browser-based tool.  

Here Below is a list of file names. We want to write a regular expression that captures parts of each string. Copy the text below into the browser window.

...

In R, again write an expression that captures each of the three components of each name separately (leaving off the “.csv”), but further modify the text to be all upper-case.

Further topics Regular expression components (see ?regexp in R):

  1. character classes

    1. POSIX names [:alnum:] [:alpha:] [:digit:] [:lower:] [:upper:] [:blank:]

    2. sometimes shortcuts like \w or \s

    3. . (any character)

  2. enumerators: *, +, ?, [1,10], [2,]

  3. anchors: ^ (beginning of string) and $ (end of string)

  4. capturing matches and backreferencing, using () for capturing and $1 or \1 for backreferencing

...