Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression in Rstudio's "Find in files"

Tags:

r

rstudio

How do I use regular expressions in Rstudio's "Find in files"?

Searching for literal numbers work just fine:

enter image description here

But when trying to use a regular expression to find a number I can't:

enter image description here

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?

like image 642
Rasmus Larsen Avatar asked Mar 25 '19 14:03

Rasmus Larsen


People also ask

How do I search all R files?

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.

What does regex 0 * 1 * 0 * 1 * Mean?

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.

What is a regex file?

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.


1 Answers

RStudio uses POSIX Basic Regular Expressions for its "Find in files" functionality (because it is using grep under the hood).

like image 200
Gustav Delius Avatar answered Sep 29 '22 17:09

Gustav Delius