mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
22
server/core/helpers/regexp.ts
Normal file
22
server/core/helpers/regexp.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Thanks to https://regex101.com
|
||||
function regexpCapture (str: string, regex: RegExp, maxIterations = 100) {
|
||||
const result: RegExpExecArray[] = []
|
||||
let m: RegExpExecArray
|
||||
let i = 0
|
||||
|
||||
while ((m = regex.exec(str)) !== null && i < maxIterations) {
|
||||
// This is necessary to avoid infinite loops with zero-width matches
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++
|
||||
}
|
||||
|
||||
result.push(m)
|
||||
i++
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export {
|
||||
regexpCapture
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue