What do you think about regular expressions? I guess you’d say it’s too obscure, I’m not interested in it at all. Yes, I used to be like you and thought I would never learn it in my life.
But we can’t deny that it’s really powerful, I use it a lot at work, and I’ve summed up 15 tips to share with you.
If you are interested in how they are implemented, you are very welcome to tell me in the comment area, and I will write another article to analyze it separately.
1. Format money
I often need to format money and it needs to follow these rules:
You can imagine how we would do this without regular expressions?
2. Two ways to implement a trim function
Sometimes we need to remove the leading and trailing spaces of the string, it will be very convenient to use regular expressions, I want to share with you at least two ways.
Great, we have removed the leading and trailing spaces of the string ‘string’.