npm install matching.js -S
or
yarn add matching.js
import matching from 'matching.js'
matching('interface *highlight code* end', {
startChar: '*',
endChar: '*',
cb: (str) => (<span className="hign-light">{str}</span>)
})
// output
['interface', <span className="hign-light">highlight code</span>, ' end']
type Matching<T = any> = (str: string, option: Option<T>) => T[]
interface Option<T> {
/**
* start chartacter
*/
startChar: string
/**
* end chartacter
*/
endChar: string
/**
* matching map
*/
cb?: (str: string) => T
/**
* greedy mode
*/
isGreedy?: boolean
}