I have a simple question about regular expression and Im new to php so sry about my bad questions , what is the meaning of ^ and $ in regular expression and please give examples that if we dont put them it will go wrong . thank you

and what about | ? in regular expression ?

I suggest you read the full tutorial first. If you still have questions afterwards, come back here.