cursor-match

    0.0.6 • Public • Published

    cursor-match

    Finds a fragmented string within a text body.

    const match = require('cursor-match')
    const str = 'Hello world'
    const text = '<span class="icon"></span>Hello \n<p>world</p>!'
    match(str, text) // 'Hello \n<p>world'

    options

    • ignoreHtml - decides whether to ignore html tags in the search (default: true)
    • threshold - decides how many non-matches will be accepted until a cursor is discarded (default: 10)
    • confidence - decides when the algorithm stops adding cursors and assumes a match has been found, by defining a confidence level about a given cursor's position in respect of the total string (default: 1, i.e. ignore)
    match(str, text, { threshold: 20, confidence: 0.5 }) // will stop adding cursors when any of them reaches 50% of the length of the string to be found.

    Keywords

    Install

    npm i cursor-match

    DownloadsWeekly Downloads

    2

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    5.5 kB

    Total Files

    8

    Last publish

    Collaborators

    • salvadr