[Linux OT] Regular expresion question
Jesus Antonio Santos Giraldo
jeansagi
Tue Oct 5 12:31:15 PDT 2004
If someone is interested in regular expresion check:
The Regex Coach - interactive regular expressions at
http://www.weitz.de/regex-coach/
It's very interesting and it works on linux.
Chucho!
>We should have a section something like 'shell use of the week' where
>people send these sorts of snippets with some code...
>
>I have learn't alot just following this thread...
>
>For some reason I have an "I know it's possible, but until I see it I
>can't do it" sort of head.
>
>
>Jean Sagi wrote:
>
>>
>> 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!
>
>
>_______________________________________________
>Linux-users mailing list
>Linux-users at linux-sxs.org
>http://mail.linux-sxs.org/cgi-bin/mailman/listinfo/linux-users
>
More information about the Linux-users
mailing list