URLs component-based input and output Patterns in the Python language.
Matching URLs against Regular Expressions is straight forward, however outputting those URLs given a certain pattern is not.
Pattern is a Python module to match URL strings against INPUT PATTERNS and output new URL strings based on OUTPUT PATTERN.
This library was made for filtering adult content in private networks.
- New feature syntax:
<re:regex:end>
, regex: can take any regular expression syntax.
URL syntax: <scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]
Input pattern: <*>://youtube.com/<*>/watch?<*>v=<*>#<*>
Testing URL: http://www.youtube.com/watch?v=xyz
Match Result: True
Output pattern: <s>://youtube.com/<q=v:name>/<q=v:value>
Result URLs: http://youtube.com/v/xyz
Input pattern: <*>://twitter.com/<*>#!/<*>
Testing URL: http://twitter.com/#!/xyz
Match Result: True
Output pattern: <s>://twitter.com/users/show_for_profile.json?screen_name=<f:[2,]>
Output pattern: <s>://twitter.com/users/<f>
Result URLs: http://twitter.com/users/show_for_profile.json?screen_name=xyz
Result URLs: http://twitter.com/users/!/xyz