# Grouping and Capturing

{% embed url="<https://www.hackerrank.com/domains/regex?filters%5Bsubdomains%5D%5B%5D=grouping-and-capturing>" %}

## Matching Word Boundaries

You have a test String S. Your task is to write a regex which will match word starting with vowel (a,e,i,o, u, A, E, I , O or U). The matched word can be of any length. The matched word should consist of letters (lowercase and uppercase both) only. The matched word must start and end with a word boundary.

```regex
\b[aeiouAEIOU][a-zA-Z]*\b
```

***

## Capturing and Non-Capturing Groups

You have a test String S.\
Your task is to write a regex which will match S with the following condition:

* S should have 3 or more consecutive repetitions of **`ok`**.

```regex
(ok){3,}
```

***

## Alternative Matching

Given a test string, s, write a RegEx that matches s under the following conditions:

* &#x20;must start with `Mr.`, `Mrs.`, `Ms.`, `Dr.` or `Er.`.
* The rest of the string must contain only *one or more* English alphabetic letters (upper and lowercase).

```regex
^(Mr\.|Mrs\.|Ms\.|Dr\.|Er\.)[a-zA-Z]+$
```


---

# 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://thamizhiniyancs.gitbook.io/writeups/hackerrank/regex/grouping-and-capturing.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.
