Extending R.E. Syntax (was: Re: Eliminating binary from a text file)

Extending R.E. Syntax (was: Re: Eliminating binary from a text file)

Shlomi Fish shlomif at gmail.com
Tue Jul 21 13:34:58 IDT 2015


Hi Omer,

On Mon, Jul 20, 2015 at 9:46 PM, Omer Zak <w1 at zak.co.il> wrote:

> Instead of creating a separate bgrep, it would have been better to be
> able to extend the syntax of regular expressions (in egrep, Perl and
> other platforms) to allow specification of binary strings having
> arbitrary length by means of an hex string.
>
> This would come instead of making it very cumbersome to specify strings
> longer than one character (\xnn or \unnnn or equivalent - see also:
> http://www.regular-expressions.info/unicode.html).
>
>
Well, you can already match binary sub-strings inside Perl regular
expressions using the method you describe (\xHH\xHH\xHH . etc.) In Perl
you can do something like:

my $bin_string = [Binary string generated by whatever means necesary]

if ($haystack =~ / ... \Q$bin_string\E ... /)
{
}

So given the rarity of matching binary strings, it seems like a good
compromise.

And if we are at it, it would have been nice to add to all R.E. engines
> hooks to allow private extensions of R.E. syntax, in order to allow
> people to concisely express special parsing requirements.
>
>
Recent versions of perl 5 allow you to use different (and possibly custom)
regular expression engines.

Regards,

-- Shlomi



> --- Omer
>
>
-- 
------------------------------------------
Shlomi Fish http://www.shlomifish.org/

Chuck Norris helps the gods that help themselves.

Please reply to list if it's a mailing list post - http://shlom.in/reply .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20150721/b3db2253/attachment.html>


More information about the Linux-il mailing list