Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/capaj/index-of-regex

a tiny utility for indexOf and lastIndexOf methods that accept regexes based on http://stackoverflow.com/a/274094
https://github.com/capaj/index-of-regex

regex utility

Last synced: 8 days ago
JSON representation

a tiny utility for indexOf and lastIndexOf methods that accept regexes based on http://stackoverflow.com/a/274094

Awesome Lists containing this project

README

        

# index-of-regex

## Install
```bash
npm i index-of-regex
```

## Usage

```javascript
//es6
import {indexOfRegex, lastIndexOfRegex} from 'index-of-regex'

const {indexOfRegex, lastIndexOfRegex} = require('index-of-regex')

const str = '123abcabc'

indexOfRegex(str, /ab/) // 3
lastIndexOfRegex(str, /ab/) //6
```
Both take `startPosition` as 3rd argument.

Original credit to Jason Bunting: http://stackoverflow.com/a/274094