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

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

Re: Regex to match lines with a specific number of words


From: Stefan Monnier
Subject: Re: Regex to match lines with a specific number of words
Date: Sat, 23 Apr 2022 18:46:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>> \([^[:space:]]+[[:space:]]+\)\{30,\}

I don't think yo want to match more than 30 times: as soon as you have
30 repetitions you know what to do.
And indeed you should likely anchor your regexp at beg of line (but not
end of line, since you want to ignore the rest of the line after matching
30 repetitions).

Note also that regardless if [:space:] matches line-feed or not, one of
[[:space:]] or [^[:space:]] will match line-feed.

Personally, I'd go with something like:

    ^\([^\n\t ]+[\t ]+\)\{30\}

[ Tho, IIUC `flush-lines` doesn't know \t and \n, so you'll probably
  need C-q C-j and C-q TAB.  ]


        Stefan




reply via email to

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