When an key is pressed in an input I call this on its value
.trim().replace(/ /g, '.').replace(/[^\w .-]/gi, '').toLowerCase();
what I want to do is, when the value is submitted to the server I want to do a function that will take the value, fun the php version of this function over it, and if the new string is different to the original string return false, else return true.
So, What is the php equivelent of the above line of code?
obviously I can use strtolower(str_replace(' ', '.', trim($value)))
which means I just need to equivelent of .replace(/[^\w .-]/gi, '')
Notes: The global flag g is not needed in php. Flag i is not necessary for \w.
And as a side note: You don’t actually need the space in the character class because you removed spaces already.