emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rx.el sexp regexp syntax


From: Eric Abrahamsen
Subject: Re: rx.el sexp regexp syntax
Date: Sun, 03 Jun 2018 14:15:11 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Drew Adams <address@hidden> writes:

> It's not just about confusion/obscurity due to the "extra"
> backslashes (for `(', `)', and `|').  It's also about the
> fact that regexps themselves can be complicated.  For
> example, `directory-listing-before-filename-regexp':
>
> "\\([0-9][BkKMGTPEZY]?
> \\(\\([0-9][0-9][0-9][0-9]-\\)?[01][0-9]-[0-3][0-9][ T][
> 0-2][0-9][:.][0-5][0-9]\\(:[0-6][0-9]\\([.,][0-9]+\\)?\\(
> ?[-+][0-2][0-9][0-5][0-9]\\)?\\)?\\|[0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]\\)\\|.*[0-9][BkKMGTPEZY]?
> \\(\\(\\([A-Za-z']\\|[^\0-]\\)\\([A-Za-z']\\|[^\0-]\\)+\\.? +[
> 0-3][0-9]\\|[ 0-3][0-9]\\.?
> \\([A-Za-z']\\|[^\0-]\\)\\([A-Za-z']\\|[^\0-]\\)+\\.?\\) +\\([
> 0-2][0-9][:.][0-5][0-9]\\|[0-9][0-9][0-9][0-9]\\)\\|\\([A-Za-z']\\|[^\0-]\\)\\([A-Za-z']\\|[^\0-]\\)+\\.?
> +[ 0-3][0-9], +[0-9][0-9][0-9][0-9]\\|\\([
> 0-1]?[0-9]\\([A-Za-z]\\|[^\0-]\\)? [
> 0-3][0-9]\\([A-Za-z]\\|[^\0-]\\)? +\\|[ 0-3][0-9] [ 0-1]?[0-9]
> +\\)\\([
> 0-2][0-9][:.][0-5][0-9]\\|[0-9][0-9][0-9][0-9]\\([A-Za-z]\\|[^\0-]\\)?\\)\\)\\)
> +"
>
> Even after removing "extra" backslashes, it's still a bear:
>
> "([0-9][BkKMGTPEZY]? (([0-9][0-9][0-9][0-9]-)?[01][0-9]-[0-3][0-9][
> T][ 0-2][0-9][:.][0-5][0-9](:[0-6][0-9]([.,][0-9]+)?(
> ?[-+][0-2][0-9][0-5][0-9])?)?|[0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9])|.*[0-9][BkKMGTPEZY]?
> ((([A-Za-z']|[^\0-])([A-Za-z']|[^\0-])+\\.? +[ 0-3][0-9]|[
> 0-3][0-9]\\.? ([A-Za-z']|[^\0-])([A-Za-z']|[^\0-])+\\.?) +([
> 0-2][0-9][:.][0-5][0-9]|[0-9][0-9][0-9][0-9])|([A-Za-z']|[^\0-])([A-Za-z']|[^\0-])+\\.?
> +[ 0-3][0-9], +[0-9][0-9][0-9][0-9]|([ 0-1]?[0-9]([A-Za-z]|[^\0-])?
> [ 0-3][0-9]([A-Za-z]|[^\0-])? +|[ 0-3][0-9] [ 0-1]?[0-9] +)([
> 0-2][0-9][:.][0-5][0-9]|[0-9][0-9][0-9][0-9]([A-Za-z]|[^\0-])?))) +"

Sure -- the way I was thinking of it, anyway, you'd use a "pcre" macro
for simpler regexp, and `rx' for more complicated ones. The line between
simple and complex being drawn in a different place for each coder,
obviously. Though I think anyone would benefit from seeing that filename
regexp in `rx'!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]