Compare commits

...

1 Commits

Author SHA1 Message Date
Rıdvan Akca
f4a2e1a84b feat(formatter): add replace with regex action 2024-04-29 11:38:54 +02:00
4 changed files with 44 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import htmlToMarkdown from './transformers/html-to-markdown.js';
import lowercase from './transformers/lowercase.js';
import markdownToHtml from './transformers/markdown-to-html.js';
import pluralize from './transformers/pluralize.js';
import replaceWithRegEx from './transformers/replace-with-regex.js';
import replace from './transformers/replace.js';
import stringToBase64 from './transformers/string-to-base64.js';
import trimWhitespace from './transformers/trim-whitespace.js';
@@ -22,6 +23,7 @@ const transformers = {
lowercase,
markdownToHtml,
pluralize,
replaceWithRegEx,
replace,
stringToBase64,
trimWhitespace,
@@ -49,6 +51,7 @@ export default defineAction({
{ label: 'Extract Number', value: 'extractNumber' },
{ label: 'Lowercase', value: 'lowercase' },
{ label: 'Pluralize', value: 'pluralize' },
{ label: 'Replace with RegEx', value: 'replaceWithRegEx' },
{ label: 'Replace', value: 'replace' },
{ label: 'String to Base64', value: 'stringToBase64' },
{ label: 'Trim Whitespace', value: 'trimWhitespace' },

View File

@@ -0,0 +1,10 @@
const replaceWithRegEx = ($) => {
const input = $.step.parameters.input;
const find = new RegExp($.step.parameters.find);
const replace = $.step.parameters.replace;
return input.replace(find, replace);
};
export default replaceWithRegEx;

View File

@@ -6,6 +6,7 @@ import htmlToMarkdown from './text/html-to-markdown.js';
import lowercase from './text/lowercase.js';
import markdownToHtml from './text/markdown-to-html.js';
import pluralize from './text/pluralize.js';
import replaceWithRegEx from './text/replace-with-regex.js';
import replace from './text/replace.js';
import stringToBase64 from './text/string-to-base64.js';
import trimWhitespace from './text/trim-whitespace.js';
@@ -25,6 +26,7 @@ const options = {
lowercase,
markdownToHtml,
pluralize,
replaceWithRegEx,
replace,
stringToBase64,
trimWhitespace,

View File

@@ -0,0 +1,29 @@
const replaceWithRegEx = [
{
label: 'Input',
key: 'input',
type: 'string',
required: true,
description:
'Text that you want to search for and replace values with regex.',
variables: true,
},
{
label: 'Find',
key: 'find',
type: 'string',
required: true,
description: 'RegEx that will be searched for.',
variables: true,
},
{
label: 'Replace',
key: 'replace',
type: 'string',
required: false,
description: 'Text that will replace the found regex.',
variables: true,
},
];
export default replaceWithRegEx;