Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions static/extensions/DogeisCut/dogeiscutRegularExpressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@
},
...dogeiscutRegularExpression.Block
},
{
opcode: 'clone',
text: 'clone [REGEX]',
arguments: {
REGEX: dogeiscutRegularExpression.Argument,
},
...dogeiscutRegularExpression.Block
},
{
opcode: 'escape',
text: 'escape [STRING] for regex',
Expand Down Expand Up @@ -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',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no block definition?

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 : {}),
},
'---',
{
Expand Down Expand Up @@ -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)
Expand Down