API Documentation for JSVerbalExpressions.
View the Project on GitHub
VerbalExpressions/JSVerbalExpressions
VerEx
• VerbalExpression
replace
Replace characters matching the VerbalExpression in a string with another string.
Parameter | Expected type | Description |
---|---|---|
source |
String |
String to look for matches in |
value |
String |
String to replace matches with |
Return type: String
const spaces = VerEx().find(' ');
const fileName = 'a file name.txt';
// => 'a_file_name.txt'
console.log(spaces.replace(fileName, '_'));
toRegExp
Convert the class to a RegExp
object.
Return type: RegExp
const expr = VerEx().find('foo');
console.log(expr.toRegExp()); // => /(?:foo)/gm