Re: Regexp problem when parsing a string

2010-03-21 Thread MRAB
Alessandro Marino wrote: I'm a beginner and I was trying to write a program to parse recursively all file names in a directory specified as parameter. The problem is that I get a "None" printed to stdout when a file is positively matched. While when the file name doesn't match the regexp the o

Re: Regexp problem when parsing a string

2010-03-21 Thread Steven D'Aprano
On Sun, 21 Mar 2010 19:12:18 +0100, Alessandro Marino wrote: > Could anyone help me to figure out why "None" appears in the putput? I get: "Attachment not shown: MIME type application/octet-stream; filename a.py" Posting attachments to Usenet is tricky. Many newsgroups filter out anything they

Regexp problem when parsing a string

2010-03-21 Thread Alessandro Marino
I'm a beginner and I was trying to write a program to parse recursively all file names in a directory specified as parameter. The problem is that I get a "None" printed to stdout when a file is positively matched. While when the file name doesn't match the regexp the output seems ok. C:\>c:\python

Re: Regexp problem

2009-07-31 Thread Ethan Furman
MRAB wrote: Ethan Furman wrote: Marcus Wanner wrote: Wow, I really need to learn more about regexp... Any tutorials you guys can recommend? Marcus Mastering Regular Expressions Powerful Techniques for Perl and Other Tools By Jeffrey E. F. Friedl Great book! +1 I have the first edition,

Re: Regexp problem

2009-07-30 Thread MRAB
Ethan Furman wrote: Marcus Wanner wrote: On 7/30/2009 9:32 AM, Beldar wrote: On 30 jul, 15:07, MRAB wrote: Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to

Re: Regexp problem

2009-07-30 Thread Ethan Furman
Marcus Wanner wrote: On 7/30/2009 9:32 AM, Beldar wrote: On 30 jul, 15:07, MRAB wrote: Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to get the 'beldar' part

Re: Regexp problem

2009-07-30 Thread Peter Brett
Marcus Wanner writes: > On 7/30/2009 9:32 AM, Beldar wrote: >> On 30 jul, 15:07, MRAB wrote: >>> Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp

Re: Regexp problem

2009-07-30 Thread Marcus Wanner
On 7/30/2009 9:32 AM, Beldar wrote: On 30 jul, 15:07, MRAB wrote: Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to get the 'beldar' part, the format is 'somethin

Re: Regexp problem

2009-07-30 Thread Beldar
On 30 jul, 15:07, MRAB wrote: > Beldar wrote: > > Hi there! > > > I have a problem and i'm not very good at regular expressions. > > I have a text like "lalala lalala tiruri beldar-is-listening tiruri > > lalala" I need a regexp to get the 'beldar' part, the format is > > 'something-is-listening',

Re: Regexp problem

2009-07-30 Thread MRAB
Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to get the 'beldar' part, the format is 'something-is-listening', i need to get the something part, use it in my code

Re: Regexp problem

2009-07-30 Thread Tim Chase
I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to get the 'beldar' part, the format is 'something-is-listening', i need to get the something part, use it in my code, and then replace the who

Regexp problem

2009-07-30 Thread Beldar
Hi there! I have a problem and i'm not very good at regular expressions. I have a text like "lalala lalala tiruri beldar-is-listening tiruri lalala" I need a regexp to get the 'beldar' part, the format is 'something-is-listening', i need to get the something part, use it in my code, and then repla

Re: regexp problem in Python

2007-08-07 Thread Ant
On Aug 3, 10:41 pm, Ehsan <[EMAIL PROTECTED]> wrote: ... > what can I do? what's wrong whit this pattern? thanx for your comments Nothing. There's something wrong with the code you are using the regex with. Post it and we may be able to help. Like Lawrence has said, it's likely to be that you are

Re: regexp problem in Python

2007-08-06 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ehsan wrote: > I use this pattern : > "http.*?\.(wmv|3gp).*"" > > but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/ > download/1716611/e2000f22/Jadeed_Mlak14.wmv? > tsid=20070803-164051-9d637d11" What's the actual Python code that uses this r

Re: regexp problem in Python

2007-08-04 Thread Sönmez Kartal
On 4 A ustos, 17:10, Ehsan <[EMAIL PROTECTED]> wrote: > On Aug 4, 1:22 pm, Sönmez Kartal <[EMAIL PROTECTED]> wrote: > > > > > > > > > On 4 A ustos, 00:41, Ehsan <[EMAIL PROTECTED]> wrote: > > > > I want to find "http://www.2shared.com/download/1716611/e2000f22/ > > > Jadeed_Mlak14.wmv?tsid=20070803

Re: regexp problem in Python

2007-08-04 Thread Fabio Z Tessitore
Il Fri, 03 Aug 2007 14:41:52 -0700, Ehsan ha scritto: maybe you can use this to solve your prob: myurl = "http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" if myurl.startswith('http') and ('wmv' in myurl or '3pg' in myurl): # myurl is the

Re: regexp problem in Python

2007-08-04 Thread Ehsan
On Aug 4, 1:22 pm, Sönmez Kartal <[EMAIL PROTECTED]> wrote: > On 4 A ustos, 00:41, Ehsan <[EMAIL PROTECTED]> wrote: > > > > > > > I want to find "http://www.2shared.com/download/1716611/e2000f22/ > > Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" or 3gp instead of > > wmv in the text file like t

Re: regexp problem in Python

2007-08-04 Thread Sönmez Kartal
On 4 A ustos, 00:41, Ehsan <[EMAIL PROTECTED]> wrote: > I want to find "http://www.2shared.com/download/1716611/e2000f22/ > Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" or 3gp instead of > wmv in the text file like this : > > ""some code"" > function reportAbuse() { > var windowname="abus

Re: regexp problem in Python

2007-08-03 Thread Ehsan
On Aug 4, 1:36 am, Dave Hansen <[EMAIL PROTECTED]> wrote: > On Aug 3, 4:41 pm, Ehsan <[EMAIL PROTECTED]> wrote: > > > I want to find "http://www.2shared.com/download/1716611/e2000f22/ > [...] > > I use this pattern : > > "http.*?\.(wmv|3gp).*"" > > > but it returns only 'wmv' and '3gp' instead of "

Re: regexp problem in Python

2007-08-03 Thread Dave Hansen
On Aug 3, 4:41 pm, Ehsan <[EMAIL PROTECTED]> wrote: > I want to find "http://www.2shared.com/download/1716611/e2000f22/ [...] > I use this pattern : > "http.*?\.(wmv|3gp).*"" > > but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/ > download/1716611/e2000f22/Jadeed_Mlak14.wmv? >

regexp problem in Python

2007-08-03 Thread Ehsan
I want to find "http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" or 3gp instead of wmv in the text file like this : ""some code"" function reportAbuse() { var windowname="abuse"; var url="/abuse.jsp?link=" + "http://www.2shared.com/file/17

Re: Regexp problem with `('

2007-03-22 Thread John Nagle
Johny wrote: > I have the following text > > Goods Item 146 (174459989) - OurWebSite > > from which I need to extract > `Goods Item 146 ' > > Can anyone help with regexp? > Thank you for help > L. In general, parsing HTML with regular expressions is a bad idea. Usually, you use somethin

Re: Regexp problem with `('

2007-03-22 Thread Paul McGuire
On Mar 22, 3:26 am, "Johny" <[EMAIL PROTECTED]> wrote: > I have the following text > > Goods Item 146 (174459989) - OurWebSite > > from which I need to extract > `Goods Item 146 ' > > Can anyone help with regexp? > Thank you for help > L. Here's the immediate answer to your question. import r

Re: Regexp problem with `('

2007-03-22 Thread Bruno Desthuilliers
Johny a écrit : > I have the following text > > Goods Item 146 (174459989) - OurWebSite > > from which I need to extract > `Goods Item 146 ' > > Can anyone help with regexp? Sure : the documentation is here: http://docs.python.org/lib/module-re.html And there's a nice tutorial here: http:/

Re: Regexp problem with `('

2007-03-22 Thread Zeng Nan
On Thu, Mar 22, 2007 at 01:26:22AM -0700, Johny wrote: > I have the following text > > Goods Item 146 (174459989) - OurWebSite > > from which I need to extract > `Goods Item 146 ' > > Can anyone help with regexp? > Thank you for help > L. (Goods\s+Item\s+146\s+) -- Zeng Nan MY

Regexp problem with `('

2007-03-22 Thread Johny
I have the following text Goods Item 146 (174459989) - OurWebSite from which I need to extract `Goods Item 146 ' Can anyone help with regexp? Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regexp problem with `('

2007-03-22 Thread Steve Holden
Zeng Nan wrote: > On Thu, Mar 22, 2007 at 01:26:22AM -0700, Johny wrote: >> I have the following text >> >> Goods Item 146 (174459989) - OurWebSite >> >> from which I need to extract >> `Goods Item 146 ' >> >> Can anyone help with regexp? >> Thank you for help >> L. > > (Goods\s+Item\s+146\s+)

Regexp problem, which pattern to use in split

2004-12-14 Thread Hans Almåsbakk
Hi, I have a problem which I believe is seen before: Finding the correct pattern to use, in order to split a line correctly, using the split function in the re module. I'm new to regexp, and it isn't always easy to comprehend for a newbie :) The lines I want to split are like this: (The followin

Re: Regexp problem, which pattern to use in split

2004-12-14 Thread Fredrik Lundh
Hans Almåsbakk wrote: > Is there a relatively hassle-free way to get the csv module working with > 2.1? The server is running Debian stable/woody, and it also seemed 2.2 can > coexist with 2.1, when I checked the distro packages, if that is any help. 2.3 and 2.4 can also coexist with 2.1 (use "ma

Re: Regexp problem, which pattern to use in split

2004-12-13 Thread Hans Almåsbakk
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > >>> import csv > > http://online.effbot.org/2003_08_01_archive.htm#librarybook-csv-module > This seems be just the thing I need. Now ofcourse, another problem arouse: The csv module is new in Python 2.3. hans:~# python -V Python 2.1.3 Is there a

Re: Regexp problem, which pattern to use in split

2004-12-13 Thread Matthias Huening
Hans Almåsbakk (14.12.2004 16:02): Any pointer will be greatly appreciated. Maybe I'm attacking this problem the wrong way already from the start? (Not that I can see another way myself :) Hans, did you try the csv module in the Python library? Matthias -- http://mail.python.org/mailman/listinfo/py

Re: Regexp problem, which pattern to use in split

2004-12-13 Thread Fredrik Lundh
Hans Almåsbakk wrote: > These lines are in a csv file exported from excel. > Any pointer will be greatly appreciated. Maybe I'm attacking this problem > the wrong way already from the start? (Not that I can see another way > myself :) >>> import csv http://online.effbot.org/2003_08_01_archive.h