One trick a day: Make your regular expressions a hundred times more readable
Original link: https://www.kingname.info/2022/06/20/readable-re/ Regular expressions are powerful, but they are written like an emoji. When I look at the expression I wrote in a month, I don’t even remember what it means. For example the following: 1 pattern = r”((?:\(\s*)?[AZ]*H\d+[az]*(?:\s*\+\s*[AZ]*H\d+[az]*)* (?:\s*[\):+])?)(.*?)(?=(?:\(\s*)?[AZ]*H\d+[az]*(?:\s* \+\s*[AZ]*H\d+[az]*)*(?:\s*[\):+])?(?![^\w\s])|$)” Is there any way to improve the readability of regular expressions? We know […]
One trick a day: Make your regular expressions a hundred times more readable Read More »