I have read some tutorials on the formatting / syntax of regexes, but it is way too far over my comprehension abilities as a new coder.
I want to create a code that will do these these things:
Remove most special characters (all special characters except _ - &)
Convert Ampersand (&) to “and”
Convert spaces or underscore to dashes.
Do nothing with dashes.
Could someone please help me out with this? I’m guessing I will have to do this in multiple steps, such as:
$string = preg_replace(only the special characters I noted above in #1, ‘’, $string);
$string = str_replace(‘&’, ‘and’, $string);
$string = preg_replace(and spaces or underscores, ‘-’, $string);
EDIT:
Although, now that I look at that, if I changed the order, and did #2, and then #3, then in #1 I could just replace all special characters except dashes, with no character.