diff --git a/static/extensions/DogeisCut/dogeiscutRegularExpressions.js b/static/extensions/DogeisCut/dogeiscutRegularExpressions.js index 01172944c..e38c9c9ea 100644 --- a/static/extensions/DogeisCut/dogeiscutRegularExpressions.js +++ b/static/extensions/DogeisCut/dogeiscutRegularExpressions.js @@ -297,6 +297,14 @@ }, ...dogeiscutRegularExpression.Block }, + { + opcode: 'clone', + text: 'clone [REGEX]', + arguments: { + REGEX: dogeiscutRegularExpression.Argument, + }, + ...dogeiscutRegularExpression.Block + }, { opcode: 'escape', text: 'escape [STRING] for regex', @@ -424,8 +432,21 @@ defaultValue: "foo" }, }, - hideFromPalette: !vm.runtime.ext_jwArray, - ...(vm.runtime.ext_jwArray ? vm.jwArray.Block : {}), + hideFromPalette: !vm.runtime.ext_jwArray && vm.runtime.ext_divIterator, + ...(vm.runtime.ext_jwArray && !vm.runtime.ext_divIterator ? vm.jwArray.Block : {}), + }, + { + opcode: 'matchAllIterator', + text: 'match all [REGEX] with [STRING]', + arguments: { + REGEX: dogeiscutRegularExpression.Argument, + STRING: { + type: ArgumentType.STRING, + defaultValue: "foo" + }, + }, + hideFromPalette: !vm.runtime.ext_divIterator, + ...(vm.runtime.ext_divIterator ? vm.divIterator.Block : {}), }, '---', { @@ -496,6 +517,13 @@ return RegularExpressionType.toRegularExpression({ PATTERN, FLAGS }) } + clone({ REGEX }) { + REGEX = RegularExpressionType.toRegularExpression(REGEX) + let newRegex = RegularExpressionType.toRegularExpression({ PATTERN: REGEX.source, FLAGS: REGEX.flags }) + newRegex.lastIndex = REGEX.lastIndex + return newRegex + } + test({ STRING, REGEX }) { STRING = Cast.toString(STRING) REGEX = RegularExpressionType.toRegularExpression(REGEX)