From 71067939e392f02b7d92ed54e8967c08e414d3e6 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 12 Jan 2018 23:51:51 +0000 Subject: [PATCH] Added Regex tests and updated description --- src/core/config/OperationConfig.js | 2 +- test/tests/operations/Regex.js | 59 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/tests/operations/Regex.js diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index c5b9dd27..a6cf4380 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -2304,7 +2304,7 @@ const OperationConfig = { }, "Regular expression": { module: "Regex", - description: "Define your own regular expression (regex) to search the input data with, optionally choosing from a list of pre-defined patterns.", + description: "Define your own regular expression (regex) to search the input data with, optionally choosing from a list of pre-defined patterns.

Supports extended regex syntax including the 'dot matches all' flag, named capture groups, full unicode coverage (including \\p{} categories and scripts as well as astral codes) and recursive matching.", inputType: "string", outputType: "html", args: [ diff --git a/test/tests/operations/Regex.js b/test/tests/operations/Regex.js new file mode 100644 index 00000000..dc16910f --- /dev/null +++ b/test/tests/operations/Regex.js @@ -0,0 +1,59 @@ +/** + * StrUtils tests. + * + * @author n1474335 [n1474335@gmail.com] + * @copyright Crown Copyright 2017 + * @license Apache-2.0 + */ +import TestRegister from "../../TestRegister.js"; + +TestRegister.addTests([ + { + name: "Regex: non-HTML op", + input: "/<>", + expectedOutput: "/<>", + recipeConfig: [ + { + "op": "Regular expression", + "args": ["User defined", "", true, true, false, false, false, false, "Highlight matches"] + }, + { + "op": "Remove whitespace", + "args": [true, true, true, true, true, false] + } + ], + }, + { + name: "Regex: Dot matches all", + input: "Hello\nWorld", + expectedOutput: "Hello\nWorld", + recipeConfig: [ + { + "op": "Regular expression", + "args": ["User defined", ".+", true, true, true, false, false, false, "List matches"] + } + ], + }, + { + name: "Regex: Astral off", + input: "šŒ†šŸ˜†", + expectedOutput: "", + recipeConfig: [ + { + "op": "Regular expression", + "args": ["User defined", "\\pS", true, true, false, false, false, false, "List matches"] + } + ], + }, + { + name: "Regex: Astral on", + input: "šŒ†šŸ˜†", + expectedOutput: "šŒ†\nšŸ˜†", + recipeConfig: [ + { + "op": "Regular expression", + "args": ["User defined", "\\pS", true, true, false, false, true, false, "List matches"] + } + ], + } +]);