kanban / webapp /src /components /live-markdown-plugin /utils /findRangesWithRegex.ts
Leon4gr45's picture
Upload folder using huggingface_hub
13555f3 verified
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const findRangesWithRegex = (text: string, regex: RegExp): number[][] => {
const ranges: number[][] = []
let matches
do {
matches = regex.exec(text)
if (matches) {
ranges.push([matches.index, (matches.index + matches[0].length) - 1])
}
} while (matches)
return ranges
}
export default findRangesWithRegex