pauls-word-boundary

1.0.0 • Public • Published

pauls-word-boundary

Find the word boundaries from a given position within a string.

const {findWordBoundary} = require('pauls-word-boundary')

var str = 'https://github.com/pfrazee/pauls-word-boundary?foo=bar'

findWordBoundary(str, 2) // => {start: 0, end: 5} ('https')
findWordBoundary(str, 10) // => {start: 8, end: 13} ('github')

Currently uses this regex to determine the word boundary: /[^a-z0-9-]/i

Readme

Keywords

none

Package Sidebar

Install

npm i pauls-word-boundary

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.74 kB

Total Files

4

Last publish

Collaborators

  • pfraze