help-gnu-emacs
[Top][All Lists]
Advanced

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

[SOLVED]: Re: Help improve regular expression for 24 hours format


From: Jean Louis
Subject: [SOLVED]: Re: Help improve regular expression for 24 hours format
Date: Thu, 24 Nov 2022 17:22:02 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* tomas@tuxteam.de <tomas@tuxteam.de> [2022-11-24 13:47]:
> On Thu, Nov 24, 2022 at 01:31:00PM +0300, Jean Louis wrote:
> 
> [...]
> 
> > Do you have completed example using: 
> > (or (seq "0" (any digit)) (seq "1" (any digit)) (seq "2" (any "0-3"))) ?
> 
> I'm not supposed to be doing this now, so the rest is left as an
> exercise to the reader, alas.
> 
> Hint: look at the regexp your `rx' invocation produces and translate
> backwards from it.

I did the exercise and I came up with the below. It looks much better
this way. 🤝 Thanks much.

(defvar rcd-rx-time (rx line-start
                        (or (seq "0" (any digit)) (seq "1" (any digit)) (seq 
"2" (any "0-3")))
                        ":"
                        (seq (any "0-5") (any digit))
                        line-end)
  "Regular expression for 24 hours format")

 ➜ "^\\(?:0[[:digit:]]\\|1[[:digit:]]\\|2[0-3]\\):[0-5][[:digit:]]$"

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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