UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.19 kB
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction");class StringReplaceRegex extends APIFunction_1.APIFunction{name="$stringReplaceRegex";description="Replace something in the provided text using regular expressions.";parameters=[{name:"Text",description:"The text to work with.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Regex",description:"The regular expression to be matched.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Replacer",description:"The word to replace the match with.",type:APIFunction_1.ParamType.String,required:!1,rest:!1,defaultValue:" "},{name:"Flags",description:"The flags for the regular expression.",type:APIFunction_1.ParamType.String,required:!1,rest:!1,defaultValue:"g"}];usage="$stringReplaceRegex[text;regex;replacer?;flags?]";returns=APIFunction_1.ParamType.String;aliases=["$replaceWithRegex","$replaceRegex","$stringReplaceWithRegex"];compile=!0;async run(e,[t,r,a="",n="g"]){return r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)),r=new RegExp(r,n),t.replace(r,a)}}exports.default=StringReplaceRegex;