replaceReg
function, since version 1.4.1
categories: strings
replaceReg(subject, pattern, replacement)
perform regular expression replacement in subject
string. For more information about pattern syntax, see php preg_replace documentation.
parameters
- subject: string - input string being searched and replaced on
- pattern: string - the value being searched for
- replacement: string - the replacement value that replaces found search values
return type
string
example
replaceReg('hello there', '/e/', 'a') // hallo thara
replaceReg('April 15, 2003', '/(\w+) (\d+), (\d+)/i', '$3-$2-$1') // 2003-15-April