RegExp help

2016-02-10 Thread Larry Martell
Given this string: >>> s = """|Type=Foo ... |Side=Left""" >>> print s |Type=Foo |Side=Left I can match with this: >>> m = re.search(r'^\|Type=(.*)$\n^\|Side=(.*)$',s,re.MULTILINE) >>> print m.group(0) |Type=Foo |Side=Left >>> print m.group(1) Foo >>> print m.group(2) Left But when I try and

Re: RegExp help

2016-02-10 Thread MRAB
On 2016-02-11 02:48, Larry Martell wrote: Given this string: s = """|Type=Foo ... |Side=Left""" print s |Type=Foo |Side=Left I can match with this: m = re.search(r'^\|Type=(.*)$\n^\|Side=(.*)$',s,re.MULTILINE) print m.group(0) |Type=Foo |Side=Left print m.group(1) Foo print

Re: RegExp help

2016-02-10 Thread Larry Martell
On Wed, Feb 10, 2016 at 10:00 PM, MRAB wrote: > On 2016-02-11 02:48, Larry Martell wrote: >> >> Given this string: >> > s = """|Type=Foo >> >> ... |Side=Left""" > > print s >> >> |Type=Foo >> |Side=Left >> >> I can match with this: >> > m =

Re: RegExp help

2016-02-10 Thread MRAB
On 2016-02-11 03:09, Larry Martell wrote: On Wed, Feb 10, 2016 at 10:00 PM, MRAB wrote: On 2016-02-11 02:48, Larry Martell wrote: Given this string: s = """|Type=Foo ... |Side=Left""" print s |Type=Foo |Side=Left I can match with this: m =

small regexp help

2013-10-30 Thread rusi
Well it seems that we are considerably closer to a solution to the GG double-spaced crap problem. Just wondering if someone can suggest a cleanup of the regexp part Currently I have (elisp) (defun clean-gg () (interactive) 1 (replace-regexp ^ *\n *\n *$ -=\=- nil 0 (point-max)) 2

Re: small regexp help

2013-10-30 Thread jianbing . tai
On Thursday, October 31, 2013 12:56:49 AM UTC+8, rusi wrote: Well it seems that we are considerably closer to a solution to the GG double-spaced crap problem. Just wondering if someone can suggest a cleanup of the regexp part Currently I have (elisp) (defun clean-gg ()

regexp help

2009-11-04 Thread Nadav Chernin
Hello all, I'm trying to write regexp that find all files that are not with next extensions: exe|dll|ocx|py, but can't find any command that make it. Please, help me Nadav -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2009-11-04 Thread Simon Brunning
2009/11/4 Nadav Chernin nada...@qualisystems.com: I’m trying to write regexp that find all files that are not with next extensions:  exe|dll|ocx|py,  but can’t find any command that make it. http://code.activestate.com/recipes/499305/ should be a good start. Use the re module and your regex

RE: regexp help

2009-11-04 Thread Nadav Chernin
Thanks, but my question is how to write the regex. -Original Message- From: simon.brunn...@gmail.com [mailto:simon.brunn...@gmail.com] On Behalf Of Simon Brunning Sent: ד 04 נובמבר 2009 18:44 To: Nadav Chernin; Python List Subject: Re: regexp help 2009/11/4 Nadav Chernin nada

Re: regexp help

2009-11-04 Thread Simon Brunning
2009/11/4 Nadav Chernin nada...@qualisystems.com: Thanks, but my question is how to write the regex. re.match(r'.*\.(exe|dll|ocx|py)$', the_file_name) works for me. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2009-11-04 Thread Carsten Haese
Nadav Chernin wrote: Thanks, but my question is how to write the regex. See http://www.amk.ca/python/howto/regex/ . -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

RE: regexp help

2009-11-04 Thread Nadav Chernin
No, I need all files except exe|dll|ocx|py -Original Message- From: simon.brunn...@gmail.com [mailto:simon.brunn...@gmail.com] On Behalf Of Simon Brunning Sent: ד 04 נובמבר 2009 19:13 To: Nadav Chernin Cc: Python List Subject: Re: regexp help 2009/11/4 Nadav Chernin nada

Re: regexp help

2009-11-04 Thread Simon Brunning
2009/11/4 Nadav Chernin nada...@qualisystems.com: No, I need all files except exe|dll|ocx|py not re.match(r'.*\.(exe|dll|ocx|py)$', the_file_name) Now that wasn't so hard, was it? ;-) -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2009-11-04 Thread Dave Angel
Simon Brunning wrote: 2009/11/4 Nadav Chernin nada...@qualisystems.com: Thanks, but my question is how to write the regex. re.match(r'.*\.(exe|dll|ocx|py)$', the_file_name) works for me. How about: os.path.splitext(x)[1] in (.exe, .dll, .ocx, .py): DaveA --

regexp help

2009-08-27 Thread Bakes
If I were using the code: (?Pdata[0-9]+) to get an integer between 0 and 9, how would I allow it to register negative integers as well? -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2009-08-27 Thread Iuri
You can use r[+-]?\d+ to get positive and negative integers. It returns true to these strings: +123, -123, 123 On Thu, Aug 27, 2009 at 3:15 PM, Bakes ba...@ymail.com wrote: If I were using the code: (?Pdata[0-9]+) to get an integer between 0 and 9, how would I allow it to register

Re: regexp help

2009-08-27 Thread Peter Pearson
On Thu, 27 Aug 2009 11:15:59 -0700 (PDT), Bakes ba...@ymail.com wrote: If I were using the code: (?Pdata[0-9]+) to get an integer between 0 and 9, how would I allow it to register negative integers as well? (?Pdata-?[0-9]+) -- To email me, substitute nowhere-spamcop, invalid-net. --

Re: regexp help

2009-08-27 Thread Mart.
On Aug 27, 7:15 pm, Bakes ba...@ymail.com wrote: If I were using the code: (?Pdata[0-9]+) to get an integer between 0 and 9, how would I allow it to register negative integers as well? -? -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2009-08-27 Thread Paul McGuire
On Aug 27, 1:15 pm, Bakes ba...@ymail.com wrote: If I were using the code: (?Pdata[0-9]+) to get an integer between 0 and 9, how would I allow it to register negative integers as well? With that + sign in there, you will actually get an integer from 0 to 9... -- Paul --

Re: catastrophic regexp, help!

2008-06-11 Thread Maric Michaud
Le Wednesday 11 June 2008 06:20:14 cirfu, vous avez écrit : pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy. i want to find a in a big string a sentence containing Zlatan Ibrahimovic and some other text. ie return

Re: catastrophic regexp, help!

2008-06-11 Thread Maric Michaud
Le Wednesday 11 June 2008 09:08:53 Maric Michaud, vous avez écrit : this is zlatan example.' compare with 'this is zlatan example', 'z'=='.', false compare with 'this is zlatan ', 'z'=='e', false compare with 'this is zlatan', 'z'==' ', false compare with 'this is ', zlatan==zlatan, true Ah

Re: catastrophic regexp, help!

2008-06-11 Thread Chris
On Jun 11, 6:20 am, cirfu [EMAIL PROTECTED] wrote: pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy. i want to find a in a big string a sentence containing Zlatan Ibrahimovic and some other text. ie return the first

Re: catastrophic regexp, help!

2008-06-11 Thread TheSaint
On 12:20, mercoledì 11 giugno 2008 cirfu wrote: patzln = re.compile((\w* *)* zlatan ibrahimovic (\w* *)*) I think that I shouldn't put anything around the phrase you want to find. patzln = re.compile(r'.*(zlatan ibrahimovic){1,1}.*') this should do it for you. Unless searching into a special

Re: catastrophic regexp, help!

2008-06-11 Thread Peter Pearson
On Tue, 10 Jun 2008 21:20:14 -0700 (PDT), cirfu [EMAIL PROTECTED] wrote: pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy. i want to find a in a big string a sentence containing Zlatan Ibrahimovic and some other text.

Re: catastrophic regexp, help!

2008-06-11 Thread cirfu
On 11 Juni, 17:04, TheSaint [EMAIL PROTECTED] wrote: On 12:20, mercoledì 11 giugno 2008 cirfu wrote: patzln = re.compile((\w* *)* zlatan ibrahimovic (\w* *)*) I think that I shouldn't put anything around the phrase you want to find. patzln = re.compile(r'.*(zlatan ibrahimovic){1,1}.*')

Re: catastrophic regexp, help!

2008-06-11 Thread cirfu
On 11 Juni, 10:25, Chris [EMAIL PROTECTED] wrote: On Jun 11, 6:20 am, cirfu [EMAIL PROTECTED] wrote: pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy. i want to find a in a big string a sentence containing Zlatan

Re: catastrophic regexp, help!

2008-06-11 Thread alfasub000
On Jun 11, 11:07 pm, cirfu [EMAIL PROTECTED] wrote: On 11 Juni, 10:25, Chris [EMAIL PROTECTED] wrote: On Jun 11, 6:20 am, cirfu [EMAIL PROTECTED] wrote: pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy.

catastrophic regexp, help!

2008-06-10 Thread cirfu
pat = re.compile((\w* *)*) this matches all sentences. if fed the string are you crazy? i am it will return are you crazy. i want to find a in a big string a sentence containing Zlatan Ibrahimovic and some other text. ie return the first sentence containing the name Zlatan Ibrahimovic. patzln =

regexp help

2008-05-09 Thread globalrev
i want to a little stringmanipulationa nd im looking into regexps. i couldnt find out how to do: s = 'poprorinoncoce' re.sub('$o$', '$', s) should result in 'prince' $ is obv the wrng character to use bu what i mean the pattern is consonant o consonant and should be replace by just consonant.

Re: regexp help

2008-05-09 Thread Paul McGuire
On May 9, 5:19 pm, globalrev [EMAIL PROTECTED] wrote: i want to a little stringmanipulationa nd im looking into regexps. i couldnt find out how to do: s = 'poprorinoncoce' re.sub('$o$', '$', s) should result in 'prince' $ is obv the wrng character to use bu what i mean the pattern is

Re: regexp help

2008-05-09 Thread Matimus
On May 9, 3:19 pm, globalrev [EMAIL PROTECTED] wrote: i want to a little stringmanipulationa nd im looking into regexps. i couldnt find out how to do: s = 'poprorinoncoce' re.sub('$o$', '$', s) should result in 'prince' $ is obv the wrng character to use bu what i mean the pattern is

Re: regexp help

2008-05-09 Thread John Machin
Paul McGuire wrote: from re import * Perhaps you intended import re. vowels = aAeEiIoOuU cons = bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ encodeRe = re.compile(r([%s])[%s]\1 % (cons,vowels)) print encodeRe.sub(r\1,s) This is actually a little more complex than you asked - it will search

Re: regexp help

2008-05-09 Thread globalrev
ty. that was the decrypt function. i am slo writing an encrypt function. def encrypt(phrase): pattern = re.compile(r([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])) return pattern.sub(r1\o\1, phrase) doesnt work though, h becomes 1\\oh. def encrypt(phrase): pattern =

Re: regexp help

2008-05-09 Thread John Machin
globalrev wrote: ty. that was the decrypt function. i am slo writing an encrypt function. def encrypt(phrase): pattern = re.compile(r([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])) The inner pair of () are not necessary. return pattern.sub(r1\o\1, phrase) doesnt work though, h

Re: regexp help

2008-05-09 Thread globalrev
The inner pair of () are not necessary. yes they are? ty anyway, got it now. -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp help

2008-05-09 Thread John Machin
globalrev wrote: The inner pair of () are not necessary. yes they are? You are correct. I was having a flashback to a dimly remembered previous incarnation during which I used regexp software in which something like or \0 denoted the whole match (like MatchObject.group(0)) :-) --

Re: regexp help

2008-05-09 Thread Paul McGuire
On May 9, 6:52 pm, John Machin [EMAIL PROTECTED] wrote: Paul McGuire wrote: from re import * Perhaps you intended import re. Indeed I did. snip Both print prince. No they don't. The result is NameError: name 're' is not defined. Dang, now how did that work in my script? I assure you

Re: RegExp Help

2007-12-14 Thread Marc 'BlackJack' Rintsch
On Thu, 13 Dec 2007 17:49:20 -0800, Sean DiZazzo wrote: I'm wrapping up a command line util that returns xml in Python. The util is flaky, and gives me back poorly formed xml with different problems in different cases. Anyway I'm making progress. I'm not very good at regular expressions

Re: RegExp Help

2007-12-14 Thread Sean DiZazzo
On Dec 14, 12:04 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 13 Dec 2007 17:49:20 -0800, Sean DiZazzo wrote: I'm wrapping up a command line util that returns xml in Python. The util is flaky, and gives me back poorly formed xml with different problems in different cases.

Re: RegExp Help

2007-12-14 Thread Gabriel Genellina
En Fri, 14 Dec 2007 06:06:21 -0300, Sean DiZazzo [EMAIL PROTECTED] escribió: On Dec 14, 12:04 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 13 Dec 2007 17:49:20 -0800, Sean DiZazzo wrote: I'm wrapping up a command line util that returns xml in Python. The util is flaky,

Re: RegExp Help

2007-12-14 Thread Sean DiZazzo
On Dec 14, 3:06 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 14 Dec 2007 06:06:21 -0300, Sean DiZazzo [EMAIL PROTECTED] escribió: On Dec 14, 12:04 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 13 Dec 2007 17:49:20 -0800, Sean DiZazzo wrote: I'm wrapping up a

RegExp Help

2007-12-13 Thread Sean DiZazzo
Hi group, I'm wrapping up a command line util that returns xml in Python. The util is flaky, and gives me back poorly formed xml with different problems in different cases. Anyway I'm making progress. I'm not very good at regular expressions though and was wondering if someone could help with

Re: RegExp Help

2007-12-13 Thread Sean DiZazzo
On Dec 13, 5:49 pm, Sean DiZazzo [EMAIL PROTECTED] wrote: Hi group, I'm wrapping up a command line util that returns xml in Python. The util is flaky, and gives me back poorly formed xml with different problems in different cases. Anyway I'm making progress. I'm not very good at regular