> For the complete documentation index, see [llms.txt](https://til.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.devjugal.com/linux/bash/test-regular-expression-against-a-string.md).

# Test Regular Expression Against A String

In BASH we can perform regular expression on a string using `=~` operator, example is given below -

## Usage

```bash
[[ "string" =~ pattern ]]
```

## Example

```bash
if [[ "Hello" =~ "1" ]]; then echo "True"; else echo "False"; fi
False
```

***Source:*** [***Unix - StackExchange***](https://unix.stackexchange.com/a/340485)
