mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Make Split more flexible so it can be used to join
This commit is contained in:
parent
aa6890432c
commit
90d8be48d4
2 changed files with 24 additions and 8 deletions
|
@ -2125,13 +2125,13 @@ const OperationConfig = {
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
name: "Split delimiter",
|
name: "Split delimiter",
|
||||||
type: "binaryShortString",
|
type: "editableOption",
|
||||||
value: StrUtils.SPLIT_DELIM
|
value: StrUtils.SPLIT_DELIM_OPTIONS
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Join delimiter",
|
name: "Join delimiter",
|
||||||
type: "option",
|
type: "editableOption",
|
||||||
value: StrUtils.DELIMITER_OPTIONS
|
value: StrUtils.JOIN_DELIM_OPTIONS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -65,12 +65,28 @@ const StrUtils = {
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
SPLIT_DELIM: ",",
|
SPLIT_DELIM_OPTIONS: [
|
||||||
|
{name: "Line feed", value: "\\n"},
|
||||||
|
{name: "CRLF", value: "\\r\\n"},
|
||||||
|
{name: "Space", value: " "},
|
||||||
|
{name: "Comma", value: ","},
|
||||||
|
{name: "Semi-colon", value: ";"},
|
||||||
|
{name: "Colon", value: ":"},
|
||||||
|
{name: "Nothing (separate chars)", value: ""}
|
||||||
|
],
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
DELIMITER_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon", "Nothing (separate chars)"],
|
JOIN_DELIM_OPTIONS: [
|
||||||
|
{name: "Line feed", value: "\\n"},
|
||||||
|
{name: "CRLF", value: "\\r\\n"},
|
||||||
|
{name: "Space", value: " "},
|
||||||
|
{name: "Comma", value: ","},
|
||||||
|
{name: "Semi-colon", value: ";"},
|
||||||
|
{name: "Colon", value: ":"},
|
||||||
|
{name: "Nothing (join chars)", value: ""}
|
||||||
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split operation.
|
* Split operation.
|
||||||
|
@ -80,8 +96,8 @@ const StrUtils = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
runSplit: function(input, args) {
|
runSplit: function(input, args) {
|
||||||
let splitDelim = args[0] || StrUtils.SPLIT_DELIM,
|
let splitDelim = args[0],
|
||||||
joinDelim = Utils.charRep[args[1]],
|
joinDelim = args[1],
|
||||||
sections = input.split(splitDelim);
|
sections = input.split(splitDelim);
|
||||||
|
|
||||||
return sections.join(joinDelim);
|
return sections.join(joinDelim);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue