RE: Need a tutorial for 'regexpr'

2011-02-10 Thread Chris Matthews
Hi Navaneethan,

It is like riding a bicycle; initially you falter a bit but later you ride with 
style.

See http://www.regular-expressions.info/tutorial.html and 
http://www.regular-expressions.info/javascript.html

Try not to build too complex expressions; always think of the guy who has to 
maintain it long after you have coded it.

Run /Python26/Tools/Scripts/redemo.py to interactively test your regular 
expressions. It works really well.
If you want to use and see named groups you can update redemo.py with:
Between line 150 and 151: 
 self.grouplist.insert(END, g)
nmatches = nmatches + 1

Insert (de-dented once, same as for line 148):
#_Start Chris Matthews 
10 May 2005
self.grouplist.insert(END, "Named Groups:")
GroupDict = m.groupdict()
if GroupDict:
   self.grouplist.insert(END, "{")
   keysGroupDict = GroupDict.keys()
   keysGroupDict.sort()
   for Name in keysGroupDict:
  self.grouplist.insert(END, "'%s': '%s'" % (Name, 
GroupDict[Name]))
   self.grouplist.insert(END, "}")
lstFindAll = self.compiled.findall(text)
self.grouplist.insert(END, "\nFindAll: %s" % (lstFindAll))

   
Here is a nice quick reference to print and keep close by:
=
 Regular Expression Primitive Quick Reference
Regular expressions can contain both special and ordinary characters. Most 
ordinary characters, like "A", "a", or "0", are the simplest regular 
expressions; they simply match themselves. You can concatenate ordinary 
characters, so last matches the string 'last'. 
Some characters, like "|" or "(", are special. Special characters either stand 
for classes of ordinary characters, or affect how the regular expressions 
around them are interpreted. 
The special characters are: 
.   (Dot.) In the default mode, this matches any character except a 
newline. 
^   (Caret.) Matches the start of the string. 
$   Matches the end of the string. 
*   Match 0 or more repetitions of the preceding RE.
+   Match 1 or more repetitions of the preceding RE. 
?   Match 0 or 1 repetitions of the preceding RE. 
{m} Specifies that exactly m copies of the previous RE should be matched. 
{m,n}   Causes the resulting RE to match from m to n repetitions of the 
preceding RE.
\   Escapes special characters ("*", "?", or \a \b \f \n \r \t \v \x \\)
[]  Range of characters e.g. [0-3A-C]  for 0123ABC,  [^5] match any except 
"5".
|   Or
()  Group
(?P...) Named group

Regular Expression Extended Quick Reference
\d  Any decimal digit; same as [0-9]. 
\D  Any non-digit character; same as [^0-9]. 
\s  Any whitespace character; same as [ \t\n\r\f\v]. 
\S  Any non-whitespace character; same as [^ \t\n\r\f\v]. 
\w  Any alphanumeric character and the underscore; same as [a-zA-Z0-9_].
\W  Any non-alphanumeric character; same as [^a-zA-Z0-9_].
=


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Kenneth Gonsalves
Sent: 11 February 2011 08:50
To: django-users@googlegroups.com
Subject: Re: Need a tutorial for 'regexpr'

On Thu, 2011-02-10 at 22:47 -0800, NavaTux wrote:
> Do you know any elegant tutorial to learn a regular 
> expression from a nutshell ? i have referred some links which are
> given in 
> a syntax without simple example, just i need a simple examples with
> clear 
> explanation even i tried in past two days to pick it 

http://www.python.org/doc//current/howto/regex.html
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need a tutorial for 'regexpr'

2011-02-10 Thread GSV
http://gskinner.com/RegExr/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need a tutorial for 'regexpr'

2011-02-10 Thread Cal Leeming [Simplicity Media Ltd]
Hey,

May I strongly recommend you use "RegexBuddy", it really helps both building
regex and also learning whilst you use it.

The main site doesn't offer a trial download, but this link does:
http://www.soft32.com/download_65244.html

Cal <3

On Fri, Feb 11, 2011 at 6:47 AM, NavaTux  wrote:

> Hi friends,
>
>Do you know any elegant tutorial to learn a regular
> expression from a nutshell ? i have referred some links which are given in
> a syntax without simple example, just i need a simple examples with clear
> explanation even i tried in past two days to pick it
>
>   Could you suggest some books or links whatever you followed?
>
>
>
> regards,
>
> Navaneethan
> http://navaspot.wordpress.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need a tutorial for 'regexpr'

2011-02-10 Thread Kenneth Gonsalves
On Thu, 2011-02-10 at 22:47 -0800, NavaTux wrote:
> Do you know any elegant tutorial to learn a regular 
> expression from a nutshell ? i have referred some links which are
> given in 
> a syntax without simple example, just i need a simple examples with
> clear 
> explanation even i tried in past two days to pick it 

http://www.python.org/doc//current/howto/regex.html
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.