Greetings-
I'm learning regular expressions and am having the most difficult of times. I've been able to grasp matching/checking okay but replacing not so much. Currently I would like to take a credit card number :
1111222233334444
and output it as such :
1111 2222 3333 4444
so yes, add a space every 4 characters. I figure I'd trim($cc_number) then add the spaces. Simple concept which doesn't help the frustration factor 😉 You think (p)ereg_replace would be best for the job? Or split? Please provide a solution, I'd be most greatful. The concepts of [0-9]{4} makes sense but putting it to use does not. I need help. Thank you.
Learning regular expressions and loving it!