How do I use regular expressions in Rstudio's "Find in files"?
Searching for literal numbers work just fine:
But when trying to use a regular expression to find a number I can't:
The documentation does not mention which type of regex is needed: https://support.rstudio.com/hc/en-us/articles/200710523-Navigating-Code
So maybe I am using a wrong flavor of regex?
Most people are familiar with command-f for searching through files; shift-command-f launches a window to search through files. You can also customize the search type for certain extensions, or to exclude stuff like . html or . md which hides duplicate results if you work with a lot of knitr.
Basically (0+1)* mathes any sequence of ones and zeroes. So, in your example (0+1)*1(0+1)* should match any sequence that has 1. It would not match 000 , but it would match 010 , 1 , 111 etc. (0+1) means 0 OR 1. 1* means any number of ones.
A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *. txt to find all text files in a file manager.
RStudio uses POSIX Basic Regular Expressions for its "Find in files" functionality (because it is using grep under the hood).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With