Cacivy / matching.js

Matching strings is simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

matching.js

Node.js CI codecov npm version

Install

npm install matching.js -S

or

yarn add matching.js

Usage

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']

Interface Type

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
}

Dev

npm start

About

Matching strings is simple

License:MIT License


Languages

Language:TypeScript 61.1%Language:JavaScript 38.9%