I'd like to suggest a possible enhancement to GNU grep.

Would it make sense to introduce an option such as --pattern-type=TYPE, 
providing predefined patterns for commonly encountered data types?

For example:
grep --pattern-type=url to match URLs.
grep --pattern-type=email to match email addresses.

One use case that prompted this idea is extracting URLs from text files. 
Currently, users have to supply their own regular expressions, which can be 
cumbersome and potentially incomplete.

Having built-in, standardized patterns would make these common tasks easier and 
avoid requiring users to reinvent the wheel.

I realize that grep is fundamentally a general-purpose pattern-matching 
utility, so I'm interested in whether the maintainers think this would fit the 
project's philosophy and design.

An inspiration for this idea is PHP's filter_var() function, which offers 
predefined filters such as FILTER_VALIDATE_URL and FILTER_VALIDATE_EMAIL. 
Something conceptually similar, adapted to grep's pattern-matching and 
extraction behaviour, might be useful?

Reply via email to