Skip to content

capaj/index-of-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

index-of-regex

Install

npm i index-of-regex

Usage

//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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published