Skip to content

isaackwok/react-use-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useRegex

A react hook for processing regular expressions.


How to use

Install react-use-regex:

# npm
npm install react-use-regex

# yarn
yarn add react-use-regex

Import and enjoy!

import useRegex from 'react-use-regex'

function MyComponent() {
  const [
    isMatch, 
    matches, 
    indexOfFirstMatch, 
    replace
  ] = useRegex(/R.*?x/i, 'Hello, Regex!')

  // isMatch: true
  // matches: ['Regex']
  // indexOfFirstMatch: 7
  // replace('World') => 'Hello, World!'

  return (
    <h1>...</h1>
  )
}

About

A react hook for processing regular expressions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published