We can now use this to grab the group letters preceeding the file extensions for our task Obviously we still have some pesky files in there that we don’t want. The filenames we want take the form project-objects or project_objects, so we know that preceeding that block of letters for “objects” we want either a dash or an underscore.We can use a group and pipe for this We still have two pesky files sneaking in there.When you finish, split your team into two groups and write each other some tests.
For example, the period in front of it to signal to the regular expression processor that you want to use the period as a plain old period and not a metacharacter.Some programs, notably many UNIX command line programs (for more on UNIX see our ‘Shell Lesson’), use an older regex standard (called ‘POSIX regular expressions’) which is less feature-rich and uses different metacharacters than Perl-influenced implementations.For the purposes of our lesson, you don’t need to worry too much about all this, but if you want to follow up on this see this detailed engine comparison.A metacharacter is any American Standard Code for Information Interchange (ASCII) character that has a special meaning.By using metacharacters and possibly literal characters, you can construct a regex for finding strings or files that match a pattern rather than a specific string.The parentheses specify a group and the pipe means “or”.Now, we could search for files ending in a certain extension or another extension. Using the pipe Now we don’t have to write surrounding expressions more than once.For example, if we wanted to extract the names of the name of all csv files then perhaps we would think to search for the string “.csv”? With regards to our task, this is already useful, as we want csv and ods files.However, you’ll notice when we searched for files contained the string “.csv”, we got files of type “.xlsx” as well, just because they had “.csv” somewhere in their name or extension. str_subset(files, "\.csv$") ##  "tmp-project.csv" "project.csv" ##  "project2-csv-specs.csv" "project-houses.csv" ##  "Project_Trees.csv" str_subset(files, "\.ods$") ##  "project_cars.ods" Round parentheses and the pipe are best used in conjuction with either other.Most regular expression implementations employ comparable syntaxes and metacharacters (generally influenced by the regex syntax of a programming language called Perl), and they behave similarly for most pattern-matching in this lesson.But there are differences, often subtle, in each, so it’s always a good practice to read the application or language’s documentation whenever available, especially when you start using more advanced regex features.