Le mer. 11 nov. 2026 à 22:32, Bert de Jonge
<[email protected]> a écrit :
>
> 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?

Hello,

I think that would be a very nice idea,
and it goes further than the scope of grep.
There should be a package commonRegularExpressions
that install on the system files
commonRegularExpressionBRE(.txt)
commonRegularExpressionERE(.txt)
commonRegularExpressionPRE(.txt)
for Basic Regular Expressions, Extended Regular Expressions, Perl
Regular Expressions
with contents like :
number:[:digit:]*
word:[:alpha:]*
...
------
number:[:digit:]*
word:[:alpha:]*
...
------
number:\d*
word:\w*
...
-----

Moreover these files could be overloaded in user space.
If there is a file
commonRegularExpressionPRE(.txt)
in the system with
----
...
my_pattern:...
...
----
and a file
commonRegularExpressionPRE(.txt)
in /home/laurent/...
with
----
my_pattern:...
----
then utilities looking at the common regular expressions
should get my_pattern from the file in user space
if the user issuing the command is laurent for example.

If such a package doesn't exist yet,
I think it would be great if you can work on it and submit it as a GNU package.

Have a nice day, best regards,
     Laurent Lyaudet



Reply via email to