In JavaScript it is possible to replace string with callback that takes matches as arguments using regular expressions.
function replacer(match, p1, p2, p3, offset, string){
// p1 is nondigits, p2 digits, and p3 non-alphanumerics
return [p1, p2, p3].join(' - ');
};
newString = "abc12345#$*%".replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
Is there a way to do something like this in Delphi? I tried to search but did not find anything useful.
anonymous methodsandregular expressions.[^\d]is synonymous with\D, and[^\w]with\W. Good luck!