This is my first post here. I've started writing a few and always managed to figure it out on my own. Alas, regular expressions make me want to beat my face on the street and I'm stuck.
I'm trying to write a regular expression that will check a string for any character that isn't an x, a, n, or -. Here's what I have:
preg_replace( '/^[^xan\-]+$/' , 'x' , $this->str_key_mask )
I'm sure it's something simple, but I've tried adding, changing, and removing metacharacters and can't get the result I want.
For instance, if I pass in xan-nax-jxy, I want to get back xan-nax-xxx due replacing the j and y with x. If I pass in xxx-aaa-nnn, it should return xxx-aaa-nnn since nothing needs replacing.