Simple regular expression

2008-06-27 Thread python_enthu
I am trying this.. what is wrong in this.. IDLE 1.2.2 import re a=my name is fname lname p=re.compile('name') m=p.match (a) print p.match(a) None findall() seems to work print p.findall(a) ['name', 'name', 'name'] -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple regular expression

2008-06-27 Thread John Machin
On Jun 28, 12:00 am, python_enthu [EMAIL PROTECTED] wrote: I am trying this.. what is wrong in this.. IDLE 1.2.2 import re a=my name is fname lname p=re.compile('name') m=p.match (a) print p.match(a) None findall() seems to work print p.findall(a) ['name', 'name', 'name'] Read

Re: Simple regular expression

2008-06-27 Thread John Salerno
python_enthu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am trying this.. what is wrong in this.. IDLE 1.2.2 import re a=my name is fname lname p=re.compile('name') m=p.match (a) print p.match(a) None match( string[, pos[, endpos]]) If zero or more characters at

Re: Simple regular expression

2008-06-27 Thread python_enthu
On Jun 27, 11:05 am, John Salerno [EMAIL PROTECTED] wrote: python_enthu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am trying this.. what is wrong in this.. IDLE 1.2.2 import re a=my name is fname lname p=re.compile('name') m=p.match (a) print p.match(a) None  

Re: Simple regular expression

2008-06-27 Thread Joel Corbin
If you read John's message carefully (which is the output of help(re.search)) you can see the difference between re.search and re.match. The former looks for a regex anywhere in the given string, the latter requires the string to begin with the given regex. Joel On Fri, Jun 27, 2008 at 12:26 PM,

Re: Simple regular expression

2008-06-27 Thread John Machin
On Jun 28, 2:26 am, python_enthu [EMAIL PROTECTED] wrote: On Jun 27, 11:05 am, John Salerno [EMAIL PROTECTED] wrote: python_enthu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am trying this.. what is wrong in this.. IDLE 1.2.2 import re a=my name is fname lname

simple regular expression problem

2007-09-17 Thread duikboot
Hello, I am trying to extract a list of strings from a text. I am looking it for hours now, googling didn't help either. Could you please help me? s = \norganisatie\nProfiel_Id28996/Profiel_Id\n/organisatie\norganisatie\nProfiel_Id28997/Profiel_Id\n/organisatie regex =

Re: simple regular expression problem

2007-09-17 Thread Jason Drew
You just need a one-character addition to your regex: regex = re.compile(r'organisatie.*?/organisatie', re.S) Note, there is now a question mark (?) after the .* By default, regular expressions are greedy and will grab as much text as possible when making a match. So your original expression

Re: simple regular expression problem

2007-09-17 Thread duikboot
Thank you very much, it works. I guess I didn't read it right. Arjen On Sep 17, 3:22 pm, Jason Drew [EMAIL PROTECTED] wrote: You just need a one-character addition to your regex: regex = re.compile(r'organisatie.*?/organisatie', re.S) Note, there is now a question mark (?) after the .* By

Re: simple regular expression problem

2007-09-17 Thread George Sakkis
On Sep 17, 9:00 am, duikboot [EMAIL PROTECTED] wrote: Hello, I am trying to extract a list of strings from a text. I am looking it for hours now, googling didn't help either. Could you please help me? s =

Re: simple regular expression problem

2007-09-17 Thread Jason Drew
You're welcome! Also, of course, parsing XML is a very common task and you might be interested in using one of the standard modules for that, e.g. http://docs.python.org/lib/module-xml.parsers.expat.html Then all the tricky parsing work has been done for you. Jason On Sep 17, 9:31 am,

Re: simple regular expression problem

2007-09-17 Thread Bruno Desthuilliers
duikboot a écrit : Hello, I am trying to extract a list of strings from a text. I am looking it for hours now, googling didn't help either. Could you please help me? s = \norganisatie\nProfiel_Id28996/Profiel_Id\n/organisatie\norganisatie\nProfiel_Id28997/Profiel_Id\n/organisatie

Re: simple regular expression problem

2007-09-17 Thread Diez B. Roggisch
duikboot wrote: Hello, I am trying to extract a list of strings from a text. I am looking it for hours now, googling didn't help either. Could you please help me? s = \norganisatie\nProfiel_Id28996/Profiel_Id\n/organisatie\norganisatie\nProfiel_Id28997/Profiel_Id\n/organisatie regex =

Re: simple regular expression problem

2007-09-17 Thread Aahz
In article [EMAIL PROTECTED], duikboot [EMAIL PROTECTED] wrote: I am trying to extract a list of strings from a text. I am looking it for hours now, googling didn't help either. To emphasize the other answers you got about avoiding regexps, here's a nice quote from my .sig database: 'Some

Hopefully simple regular expression question

2005-06-14 Thread [EMAIL PROTECTED]
I want to match a word against a string such that 'peter' is found in peter bengtsson or hey peter, or but in thepeter bengtsson or hey peterbe, because the word has to stand on its own. The following code works for a single word: def createStandaloneWordRegex(word): return a regular

Re: Hopefully simple regular expression question

2005-06-14 Thread John Machin
[EMAIL PROTECTED] wrote: I want to match a word against a string such that 'peter' is found in peter bengtsson or hey peter, or but in thepeter bengtsson or hey peterbe, because the word has to stand on its own. The following code works for a single word: def

Re: Hopefully simple regular expression question

2005-06-14 Thread Kalle Anke
On Tue, 14 Jun 2005 13:01:58 +0200, [EMAIL PROTECTED] wrote (in article [EMAIL PROTECTED]): How do I modify my regular expression to match on expressions as well as just single words?? import re def createStandaloneWordRegex(word): return a regular expression that can find 'peter' only

Re: Hopefully simple regular expression question

2005-06-14 Thread TZOTZIOY
On 14 Jun 2005 04:01:58 -0700, rumours say that [EMAIL PROTECTED] [EMAIL PROTECTED] might have written: I want to match a word against a string such that 'peter' is found in peter bengtsson or hey peter, or but in thepeter bengtsson or hey peterbe, because the word has to stand on its own. The

Re: Hopefully simple regular expression question

2005-06-14 Thread [EMAIL PROTECTED]
Thank you! I had totally forgot about that. It works. -- http://mail.python.org/mailman/listinfo/python-list