[GLLUG] Grep question

John Levin technolalia at gmail.com
Thu Oct 27 14:02:28 UTC 2022


Dear list,

In cleaning up mountains of OCR'd text, I've found Grep doing something 
I don't undesrtand.

The aim is to locate lines ending with certain punctuation marks(-—.) 
and spaces. But depending on the order of those punctuation marks, I get 
different results. With the full stop listed first, I get two results, 
one of which doesn't fit the criteria; with the stop third I get 5 lines 
correctly matching the criteria (and I presume, all the lines that do 
match).

johnl at Hasek:~/github/statutes$ grep ' [.-— ]\{3,\}$' W*/mon*.txt
and every of them are and is hereby obliged to accept, re- ...
1. s. </.~|

johnl at Hasek:~/github/statutes$ grep ' [-—. ]\{3,\}$' W*/mon*.txt
and every of them are and is hereby obliged to accept, re- ...
'fliqitors autj licences, — Aorb’s -----
IPfipficians, -----
II — -- — -.... - -- - - - —
shall be ~ - - —

Is there something about the order of characters in regex square 
brackets? Does the stop have a special meaning when given first?

Thanks in advance,

John



More information about the GLLUG mailing list