Re: [Tutor] Re Module

2018-12-27 Thread Avi Gross
rhaps doing a little debugging. -Original Message- From: Tutor On Behalf Of Asad Sent: Thursday, December 27, 2018 10:10 AM To: tutor@python.org Subject: [Tutor] Re Module Hi All , I trying find a solution for my script , I have two files : file1 - I need a search a error sa

Re: [Tutor] Re Module

2018-12-27 Thread Steven D'Aprano
On Thu, Dec 27, 2018 at 08:40:12PM +0530, Asad wrote: > Hi All , > > I trying find a solution for my script , I have two files : > > file1 - I need a search a error say x if the error matches > > Look for the same error x in other file 2 > > Here is the code : > I have 10 different

Re: [Tutor] Re Module

2018-12-27 Thread Alan Gauld via Tutor
On 27/12/2018 15:10, Asad wrote: > file1 - I need a search a error say x if the error matches > > Look for the same error x in other file 2 > > Here is the code : > I have 10 different patterns therefore I used list comprehension and > compiling the pattern so I loop over and find the exact

[Tutor] Re Module

2018-12-27 Thread Asad
Hi All , I trying find a solution for my script , I have two files : file1 - I need a search a error say x if the error matches Look for the same error x in other file 2 Here is the code : I have 10 different patterns therefore I used list comprehension and compiling the pattern so I

Re: [Tutor] re module

2014-08-19 Thread Sunil Tech
Hey thanks Danny Yoo, Chris “Kwpolska” Warrick, D.V.N Sarma ​. I will take all your inputs. Thanks a lot.​ On Fri, Aug 15, 2014 at 3:32 AM, Danny Yoo d...@hashcollision.org wrote: On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote: I tested it on IDLE. It

[Tutor] re module

2014-08-14 Thread Sunil Tech
Hi, I have string like stmt = 'pspan style=font-size: 11pt;span style=font-family: times new roman,times;Patient name:nbsp;Upadhyay Shyam/spanspan style=font-family: times new roman,times;nbsp;nbsp;br /Date of birth:nbsp;nbsp;nbsp;08/08/1988 br /Issue(s) to be

Re: [Tutor] re module

2014-08-14 Thread Chris “Kwpolska” Warrick
On 14 Aug 2014 15:58 Sunil Tech sunil.tech...@gmail.com wrote: Hi, I have string like stmt = 'pspan style=font-size: 11pt;span style=font-family: times new roman,times;Patient name:nbsp;Upadhyay Shyam/spanspan style=font-family: times new roman,times;nbsp;nbsp;br /Date of

Re: [Tutor] re module

2014-08-14 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I tested it on IDLE. It works. regards, Sarma. On Thu, Aug 14, 2014 at 7:37 PM, Chris “Kwpolska” Warrick kwpol...@gmail.com wrote: On 14 Aug 2014 15:58 Sunil Tech sunil.tech...@gmail.com wrote: Hi, I have string like stmt = 'pspan style=font-size: 11pt;span style=font-family:

Re: [Tutor] re module

2014-08-14 Thread Albert-Jan Roskam
- On Thu, Aug 14, 2014 4:07 PM CEST Chris “Kwpolska” Warrick wrote: On 14 Aug 2014 15:58 Sunil Tech sunil.tech...@gmail.com wrote: Hi, I have string like stmt = 'pspan style=font-size: 11pt;span style=font-family: times new roman,times;Patient name: Upadhyay

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote: I tested it on IDLE. It works. Hi Sarma, Following up on this one. I'm pretty sure that: print re.search(span style=\(.*)\, stmt).group() is going to print something, but it almost certainly will not

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
Hi Sunil, Don't use regular expressions for this task. Use something that knows about HTML structure. As others have noted, the Beautiful Soup or lxml libraries are probably a much better choice here. There are good reasons to avoid regexp for the task you're trying to do. For example, your

Re: [Tutor] re module- puzzling results when matching money

2013-08-04 Thread Dominik George
Hi, not quite. The moral is to learn about greedy and non-greedy matching ;)! -nik Alex Kleider aklei...@sonic.net schrieb: On 2013-08-03 13:38, Dominik George wrote: Hi, b is defined as all non-word characters, so it is the complement oft w. w is [A-Za-z0-9_-], so b includes $ and thus

Re: [Tutor] re module- puzzling results when matching money

2013-08-04 Thread Alan Gauld
On 04/08/13 08:45, Alex Kleider wrote: sorry, my bad. I forgot to delete that backslash, I meant re.findall(r\be\b, d e f). Same with the other example. ..but the interesting thing is that the presence or absence of the spurious back slashes seems not to change the results. It wouldn't

Re: [Tutor] re module- puzzling results when matching money

2013-08-03 Thread Dominik George
Hi, \b is defined as all non-word characters, so it is the complement oft \w. \w is [A-Za-z0-9_-], so \b includes \$ and thus cuts off your sign group. -nik Alex Kleider aklei...@sonic.net schrieb: #!/usr/bin/env python I've been puzzling over the re module and have a couple of questions

[Tutor] re module help

2012-01-09 Thread Ganesh Kumar
Hi Gurus, I have created regular expression with os modules, I have created file sdptool to match the regular expression pattern, will print the result. I want without creating file how to get required output, I tried but i didn't get output correctly, over stream. #! /usr/bin/python import

Re: [Tutor] re module help

2012-01-09 Thread bodsda
@python.org Date: Mon, 9 Jan 2012 14:47:46 To: tutor@python.org Subject: [Tutor] re module help ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: Recall: re.subn(r'([^\\])?', r'\1\\', expression) Traceback (most recent call last): File stdin, line 1, inmodule File /home/karim/build/python/install/lib/python2.7/re.py, line 162, in subn return _compile(pattern, flags).subn(repl, string, count)

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: That is not the thing I want. I want to escape any which are not already escaped. The sed regex '/\([^\\]\)\?/\1\\/g' is exactly what I need (I have made regex on unix since 15 years). Can the backslash be escaped, too? If so I don't think your regex does what you think it

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 02:36 AM, Steven D'Aprano wrote: Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said,

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello, Any news on this topic?O:-) Regards Karim On 02/02/2011 08:21 PM, Karim wrote: Hello, I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
Karim wrote: Hello, I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: You don't have to escape quotes. Just use the other sort of quote: print '' * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello Steven, I am perhaps a poor tradesman but I have to blame my thunderbird tool :-P . Because expression = *' '* is in fact fact expression = ' '. The bold appear as stars I don't know why. I need to have escapes for passing it to another language (TCL interpreter). So I will rewrite

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
I forget something. There is no issue with python and double quotes. But I need to give it to TCL script but as TCL is shit string is only delimited by double quotes. Thus I need to escape it to not have syntax error whith nested double quotes. Regards The poor tradesman On 02/03/2011

Re: [Tutor] RE module is working ?

2011-02-03 Thread Peter Otten
Karim wrote: I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information.

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright,

Re: [Tutor] RE module is working ?

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 11:20 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 07:47 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3]

Re: [Tutor] RE module is working ?

2011-02-03 Thread Alan Gauld
Karim karim.liat...@free.fr wrote Because expression = *' '* is in fact fact expression = ' '. The bold appear as stars I don't know why. Because in the days when email was always sent in plain ASCII text the way to show bold was to put asterisks around it. Underlining used

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said, Doctor, every time I do this, it hurts. What

[Tutor] RE module is working ?

2011-02-02 Thread Karim
Hello, I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. expression =

[Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
Hi! I am trying to split some lists out of a single text file, and I am having a hard time. I have reduced the problem to the following one: text = a2345b. f325. a45453b. a325643b. a435643b. g234324b. Of this line of text, I want to take out strings where all words start with a, end with b..

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
Hey Tiago, text = a2345b. f325. a45453b. a325643b. a435643b. g234324b. Of this line of text, I want to take out strings where all words start with a, end with b.. But I don't want a list of words. I want that: [a2345b., a45453b. a325643b. a435643b.] Are you saying you want a list of every

Re: [Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
Serdar Tumgoren zstumgo...@gmail.com writes: Hey Tiago, text = a2345b. f325. a45453b. a325643b. a435643b. g234324b. Of this line of text, I want to take out strings where all words start with a, end with b.. But I don't want a list of words. I want that: [a2345b., a45453b. a325643b.

Re: [Tutor] re module / separator

2009-06-24 Thread Kent Johnson
On Wed, Jun 24, 2009 at 2:24 PM, Tiago Sabogatiagosab...@gmail.com wrote: Hi! I am trying to split some lists out of a single text file, and I am having a hard time. I have reduced the problem to the following one: text = a2345b. f325. a45453b. a325643b. a435643b. g234324b. Of this line of

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
As usual, Kent Johnson has swooped in an untangled the mess with a clear explanation. By the time a regex gets this complicated, I typically start thinking of ways to simplify or avoid them altogether. Below is the code I came up with. It goes through some gymnastics and can surely stand

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
Ok -- realized my solution incorrectly strips white space from multiword strings: Out[92]: ['a2345b.', 'a45453b.a325643b.a435643b.'] So here are some more gymnastics to get the correct result: In [105]: newlist Out[105]: ['a2345b.', '|', 'a45453b.', 'a325643b.', 'a435643b.', '|'] In [109]:

[Tutor] Re: Module Loop doesn't work (Joseph Q.)

2005-04-01 Thread Andrei
Joseph Quigley wrote on Fri, 01 Apr 2005 10:07:08 -0600: I have some code on a geek dictionary that I'm making where the command geeker() opens a module for the real geek dictionary (where you can type a word to see what it is geekified). Supposedly, you type lobby() to go back to what I