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: Drew Adams
Subject: RE: rx.el sexp regexp syntax
Date: Sun, 3 Jun 2018 12:57:57 -0700 (PDT)

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-])?))) +"

As I said before:

 > Functions that transform a regexp string to an RX
 > sexp and vice versa would be very helpful.

(And yes, the latter exists.)

Ideally, we'd have the ability to put your cursor on
a regexp in some code and hit a key to:

 * see a corresponding `rx' sexp and
 * optionally replace the regexp with the `rx' sexp.

Just being able to see the `rx' sexp that corresponds
to a regexp in some code (even temporarily in a popup)
could help, I think.



reply via email to

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