Python Tips : Regular Expression usage to exclude something

Let’s say we want to match every single rain variation ..

“Isolated rain over coastal area” is rain.
“Scattered rain over inland area” is rain.
“Rain” is rain
but not “No rain” .. is Fair weather ..

import re
z = 1
y = 2
x = 3
if (z == 1) & (x == 3) & (y == 2):
 print "match"
 print "not match"
norain = 'No rain'
rain = 'Rain'
rainfall = 'isolated rain interne'
zrain  =re.compile ('(?<!No\s)[Rr]ain')
m_rain = (rainfall)
m2_rain = (rain)
m1_rain = (norain)
if m_rain :
  print "got rainfall"
if m2_rain :
  print "got me : Rain"
if m1_rain:
  print "no rain also defined as rain"
else :
        print "No rain is :not raining OK!"

result would be something like follows :

Related Post

One Response

  1. namran says:

    The server response can be checked as following :

    [namran@nb-namran ~]$ wget -O- --server-response 2>&1 |less

    and it should shows the response as the following

    ...--2010-11-10 23:51:18--
    Connecting to||:80... connected.
    HTTP request sent, awaiting response...
    HTTP/1.1 200 OK
    Date: Wed, 10 Nov 2010 15:51:20 GMT
    Server: Apache/2.2.3 (Red Hat)
    Last-Modified: Sun, 24 Oct 2010 08:54:00 GMT
    ETag: "5bf39c-d5-4935904475a00"
    Accept-Ranges: bytes
    Content-Length: 213
    Cache-Control: max-age=60, public, must-revalidate
    Expires: Thu, 15 Apr 2010 20:00:00 GMT
    Connection: close
    Content-Type: text/html; charset=UTF-8
    Length: 213 [text/html]
    Saving to: `STDOUT'
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <title>Loading mesinPhotostat</title>
    <meta http-equiv="REFRESH" content="0;url=http:mesinPhotostat/"></HEAD>
    Loading mesinPhotostat ...

Leave a Reply

Your email address will not be published. Required fields are marked *