Avoid escaping every non-word character

Some programmers overdo escaping, thinking that they need to escape every non-word character such as colon, hyphen, semicolon, forward slash, and whitespace, which is not correct. They end up writing a regular expression as follows:

^https?://(www.)?example.com$ 

The preceding regex pattern uses excessive escaping. This pattern still works, but it is not very readable. The colon and forward slash have no special meaning in regex; hence, it is better to write this regex in the following way:

^https?://(www.)?example.com$ 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.144.56