Re: [Tutor] Regular expression - I

2014-02-18 Thread Santosh Kumar
Thank you all. I got it. :) I need to read more between lines . On Wed, Feb 19, 2014 at 4:25 AM, spir wrote: > On 02/18/2014 08:39 PM, Zachary Ware wrote: > >> Hi Santosh, >> >> On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar >> wrote: >> >>> >>> Hi All, >>> >>> If you notice the below example,

Re: [Tutor] Regular expression - I

2014-02-18 Thread spir
On 02/18/2014 08:39 PM, Zachary Ware wrote: Hi Santosh, On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar wrote: Hi All, If you notice the below example, case I is working as expected. Case I: In [41]: string = "test" In [42]: re.match('',string).group() Out[42]: '' But why is the raw string

Re: [Tutor] Regular expression - I

2014-02-18 Thread Emile van Sebille
On 2/18/2014 11:42 AM, Mark Lawrence wrote: On 18/02/2014 18:03, Steve Willoughby wrote: Because the regular expression means “match an angle-bracket Please do not top post on this list. Appropriate trimming is also appreciated. Emile ___

Re: [Tutor] Regular expression - I

2014-02-18 Thread Albert-Jan Roskam
_ > From: Steve Willoughby >To: Santosh Kumar >Cc: python mail list >Sent: Tuesday, February 18, 2014 7:03 PM >Subject: Re: [Tutor] Regular expression - I > > >Because the regular expression means “match an angle-bracket character, &g

Re: [Tutor] Regular expression - I

2014-02-18 Thread S Tareq
does any one know how to use 2to3 program to convert 2.7 coding 3.X please i need help sorry  On Tuesday, 18 February 2014, 19:50, Zachary Ware wrote: On Tue, Feb 18, 2014 at 11:39 AM, Zachary Ware wrote: >    >>> '' >    '' > > The equivalent raw string is exactly the same in this case:

Re: [Tutor] Regular expression - I

2014-02-18 Thread Zachary Ware
On Tue, Feb 18, 2014 at 11:39 AM, Zachary Ware wrote: >>>> '' >'' > > The equivalent raw string is exactly the same in this case: > >>>> r'' >'' Oops, I mistyped both of these. The repr should be '' in both cases. Sorry for the confusion! -- Zach _

Re: [Tutor] Regular expression - I

2014-02-18 Thread Mark Lawrence
On 18/02/2014 18:03, Steve Willoughby wrote: Because the regular expression means “match an angle-bracket character, zero or more H characters, followed by a close angle-bracket character” and your string does not match that pattern. This is why it’s best to check that the match succeeded bef

Re: [Tutor] Regular expression - I

2014-02-18 Thread Zachary Ware
Hi Santosh, On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar wrote: > > Hi All, > > If you notice the below example, case I is working as expected. > > Case I: > In [41]: string = "test" > > In [42]: re.match('',string).group() > Out[42]: '' > > But why is the raw string 'r' not working as expected

Re: [Tutor] Regular expression - I

2014-02-18 Thread Steve Willoughby
Because the regular expression means “match an angle-bracket character, zero or more H characters, followed by a close angle-bracket character” and your string does not match that pattern. This is why it’s best to check that the match succeeded before going ahead to call group() on the result

Re: [Tutor] Regular expression - I

2014-02-18 Thread Steve Willoughby
The problem is not the use of the raw string, but rather the regular expression inside it. In regular expressions, the * means that whatever appears before it may be repeated zero or more times. So if you say H* that means zero or more H’s in a row. I think you mean an H followed by any numbe

Re: [Tutor] Regular expression - I

2014-02-18 Thread Santosh Kumar
Steve, i am trying to under r - raw string notation. Am i understanding it wrong. Rather than using "\", it says we can use the "r" option. http://docs.python.org/2/library/re.html Check the first paragraph for the above link. Thanks, santosh On Tue, Feb 18, 2014 at 11:33 PM, Steve Willoughb

[Tutor] Regular expression - I

2014-02-18 Thread Santosh Kumar
Hi All, If you notice the below example, case I is working as expected. Case I: In [41]: string = "test" In [42]: re.match('',string).group() Out[42]: '' But why is the raw string 'r' not working as expected ? Case II: In [43]: re.match(r'',string).group()