# Regular Expressions

In many cases, first we will have to develop a regular expression. We can use <http://www.regexr.com> to do that.

Lets say we created this regular expression `want|develop` that will find rows where there is "want" or "develop" words.

We can use regular expressions with `grep`, `grepl`, `sub`, `strsplit`, `regexpr`, `gregexpr` and `gsub` functions.

## [grep](http://stat.ethz.ch/R-manual/R-devel/library/base/html/grep.html) function

```r
> text <- "We want to develop new regular expression."
> grep("want|develop", text, value=TRUE)

[1] "We want to develop new regular expression."
```

More about [regular expressions in R](http://www.regular-expressions.info/rlanguage.html) or [here](http://stat.ethz.ch/R-manual/R-devel/library/base/html/regex.html).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ondrej-kvasnovsky-2.gitbook.io/handbook-of-hidden-data-scientist/cleaning_data/regular_expressions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
