react-use-regex
TypeScript icon, indicating that this package has built-in type declarations

0.0.2-a • Public • Published

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>
  )
}

Package Sidebar

Install

npm i react-use-regex

Weekly Downloads

156

Version

0.0.2-a

License

ISC

Unpacked Size

3.9 kB

Total Files

8

Last publish

Collaborators

  • isaackwok