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

Re: OT: regex pattern problem



> I have to find all entries in a file which match the following:
>
> (pg. 2)
> (pg. 210)
> (pg. 211)
> (pg. 309)
> (pg. 4000)

I would use:

\(pg\. [0-9]+\)

This can be explained as

\(       a ( symbol, has to be escaped as ( has meaning in regexp
pg       the letters "pg"
\.       a . symbol, has to be escpaed as . has meaning in regexp
space    a space
[0-9]+   1 or more occurences of a numerical digit
\)       a ) symbol, has to be escaped as ) has meaning in regexp

-- 
Regards,
+-----------------------------+---------------------------------+
| Peter Kiem            .^.   | E-Mail    : <zordah zordah net> |
| Zordah IT             /V\   | Mobile    : +61 0414 724 766    |
|   IT Consultancy &  /(   )\ | WWW       : www.zordah.net      |
|   Internet Services  ^^-^^  | ICQ       : "Zordah" 866661     |
+-----------------------------+---------------------------------+
       My current spamtrap address is est0104 zordah net




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