23833[Clip] Re: Twos and Threes
- May 26, 2013--- In firstname.lastname@example.org, "Adrian Worsfold"<pluralist@...> wrote:
>How do you actually explain such lines?
> ^!Replace "^.*\b(HL|SF|LS|CC|HW|HF|NB)\b.*$" >> "\r\n$0\r\n" WARS
Let me just give you an explanation for the first command line:
^ = start of line
.* = any character (except NL), zero or more times
\b = word boundary (between word character and non-word character)
(HL|...|NB) = alternation (a OR b OR c etc)
\b = another word boundary
.* = again any character till...
$ = end of line
And replace with...
\r\n = CRNL
$0 = the whole match
\r\n = another CRNL
From a stricter point of view, one would write:
This is a bit more efficient though, with a few lines, one would hardly notice the difference. At the start of each line, we see at least one character being different from '(HL|...|NB)'. So it makes no sense to search for 'zero'. It's the same condition at end of lines where we've got time data.
Since there's nothing to store, the alternation could be defined as non-capturing with '?:'. So you may want to replace the RegEx in the above mentioned command line with this better version.
> Once again many thanks are due.It's been a pleasure! It keeps me in practice. I also like the precise requirements you are posting, and the good feedback you give including a full view of what comes out in the end.
- << Previous post in topic Next post in topic >>