Regex: its usually a bane for most developers and programmers to the point that most regex patterns in the wild are usually cut and paste from the web or text books. Even I admit that I’m guilty of this.
However, wouldn’t it be better if we learn how the regex pattern we input works? Good thing is, there is already such a thing! The website strfriend transforms a RegEx pattern into a simple chart that is easier to understand.
Here is an example:

This is actually from a RegEx I used for matching all XML schema elements and attribute groups that doesn’t use a closing tag that have a ref attribute.
<xs:(element|attributeGroup) ref=”[^"\r\n]*”[^\r\n/>]*/>
For those who are curious, here is the other RegEx I used for matching those XML schema elements / attribute groups with closing tags that have a ref attribute:
<xs:(element|attributeGroup) ref=”[^"\r\n]*”[^\r\n/>]*>(.|\r\n|\n)+?</xs:(element|attributeGroup)>








Add Comment

