1.1.2 • Published 1 year ago

@laomao800/mark-match v1.1.2

Weekly downloads
69
License
MIT
Repository
github
Last release
1 year ago

mark-match

Actions Status codecov

Usage

import { markMatch, markExactMatch, hasMatch, hasExactMatch } from '@laomao800/mark-match'

// Normal match
markMatch('1234567890', '34') // -> '12<mark>34</mark>567890'

// Multiple keyword split by spaces
markMatch('1234567890', '3 6 9') // -> '12<mark>3</mark>45<mark>6</mark>78<mark>9</mark>0'

// Mark match by exact keyword include spaces
markExactMatch('1 2 3 4 5 6 7 8 9', '3 4 5') // -> '1 2 <mark>3 4 5</mark> 6 7 8 9'

// Custom match template
markMatch('1234567890', '34', match => `<span class="keyword">${match}</span>`)
markExactMatch('1234567890', '34', match => `<span class="keyword">${match}</span>`)
// -> '12<span class="keyword">34</span>567890'

// Works like `markMatch` & `markExactMatch` except is return boolean value
hasMatch('1234567890', '3 6 9') // true
hasExactMatch('1234567890', '3 6 9') // false
1.1.2

1 year ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago