[Linux OT] Regular expresion question

Jean Sagi jeansagi
Mon Oct 4 13:55:56 PDT 2004


Hi all,

Maybe anyone could help with a regular expresion for matching a rabge of 
numbers.

Lets say You a have a file, in which each line is string of the form:
hddmmyy, where h is the char 'h' and dd is a day (01..31), mm is a month 
(01..12) and yy are the last two digists of the current year.

So the file could be:

h030904
h300904
h290904
h040904
h090904
h100904
h120904
h150904
h180904
h020904
h190904
h220904
h050904
h240904
h207904

All these represent files created in some days of september this year.

What I want is to get a regular expresion wich matches a range of days, 
for example the files representing day 10 through 25 for instance, with 
the previous example the next sould match:

h100904
h120904
h150904
h180904
h190904
h220904
h240904
h207904

Some kind of this expresion

^h<range expresion>09

where <range expresion> is a pattern that matches:
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

so that files like

h100904
h110904
h120904
h130904
h140904
h150904
h160904
h170904
h180904
h190904
h200904
h210904
h220904
h230904
h240904
h250904

Be matched


I could acomplish what I'm asking with awk but I'm wondering if regular 
expresion could do the work.

Any help would be very appreciated.

Chucho!



More information about the Linux-users mailing list