1. Knowing what it is you want to match and how it might appear in the text
2. Writing a pattern to describe what you want to match
3. Testing the pattern to see what it matches
The above approach to writing regular expressions is taken from the book “sed & awk (2nd Edition)” by Dale Dougherty and Arnold Robbins. I have found that it is especially important to visit the basics when it comes to writing regular expressions and with sed, awk and vim in general. Complex expressions are best crafted by starting at the most granular level possible and then added onto until you have something that performs as expected. When approaching problems to solve keep this method in mind to get the results you expect.
Comments
(There are currently no comments for this post.)
(Comments are disabled for this post.)