Re: Regular Expression bug?

2023-03-02 Thread jose isaias cabrera
On Thu, Mar 2, 2023 at 9:56 PM Alan Bawden wrote: > > jose isaias cabrera writes: > >On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > >This re is a bit different than the one I am used. So, I am trying to match >everything after 'pn=': > >import re >s = "pm=jose pn=2017"

Re: Regular Expression bug?

2023-03-02 Thread jose isaias cabrera
ject manager. pn=project name. I needed search() rather than match(). > > >>> s = "pn=jose pn=2017" > ... > >>> s0 = r0.match(s) > >>> s0 > > > > > -Original Message- > From: Python-list On > Behalf Of jose isaias cab

Re: Regular Expression bug?

2023-03-02 Thread jose isaias cabrera
On Thu, Mar 2, 2023 at 8:30 PM Cameron Simpson wrote: > > On 02Mar2023 20:06, jose isaias cabrera wrote: > >This re is a bit different than the one I am used. So, I am trying to > >match > >everything after 'pn=': > > > >import re > >s = "pm=jose pn=2017" > >m0 = r"pn=(.+)" > >r0 = re.compile(m0)

Re: Regular Expression bug?

2023-03-02 Thread Alan Bawden
jose isaias cabrera writes: On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: This re is a bit different than the one I am used. So, I am trying to match everything after 'pn=': import re s = "pm=jose pn=2017" m0 = r"pn=(.+)" r0 = re.compile(m0) s0 = r0.match(s) >>

Re: Regular Expression bug?

2023-03-02 Thread Cameron Simpson
On 02Mar2023 20:06, jose isaias cabrera wrote: This re is a bit different than the one I am used. So, I am trying to match everything after 'pn=': import re s = "pm=jose pn=2017" m0 = r"pn=(.+)" r0 = re.compile(m0) s0 = r0.match(s) `match()` matches at the start of the string. You want r0.se

RE: Regular Expression bug?

2023-03-02 Thread avi.e.gross
;> s0 -Original Message- From: Python-list On Behalf Of jose isaias cabrera Sent: Thursday, March 2, 2023 8:07 PM To: Mats Wichmann Cc: python-list@python.org Subject: Re: Regular Expression bug? On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > > On 3/2/23 12:28

Re: Regular Expression bug?

2023-03-02 Thread jose isaias cabrera
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > > On 3/2/23 12:28, Chris Angelico wrote: > > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote: > >> > >> Greetings. > >> > >> For the RegExp Gurus, consider the following python3 code: > >> > >> import re > >> s = "pn=align upgrade sd=2

RE: Regular Expression bug?

2023-03-02 Thread avi.e.gross
José, Matching can be greedy. Did it match to the last space? What you want is a pattern that matches anything except a space (or whitespace) followed b matching a space or something similar. Or use a construct that makes matching non-greedy. Avi -Original Message- From: Python-list

Re: Regular Expression bug?

2023-03-02 Thread jose isaias cabrera
On Thu, Mar 2, 2023 at 2:32 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2023-03-02 at 14:22:41 -0500, > jose isaias cabrera wrote: > > > For the RegExp Gurus, consider the following python3 code: > > > > import re > > s = "pn=align upgrade sd=2023-02-" > > ro = re.compile(r"pn=(.+) ") >

Re: Regular Expression bug?

2023-03-02 Thread Mats Wichmann
On 3/2/23 12:28, Chris Angelico wrote: On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote: Greetings. For the RegExp Gurus, consider the following python3 code: import re s = "pn=align upgrade sd=2023-02-" ro = re.compile(r"pn=(.+) ") r0=ro.match(s) print(r0.group(1)) align upgrade T

Re: Regular Expression bug?

2023-03-02 Thread 2QdxY4RzWzUUiLuE
On 2023-03-02 at 14:22:41 -0500, jose isaias cabrera wrote: > For the RegExp Gurus, consider the following python3 code: > > import re > s = "pn=align upgrade sd=2023-02-" > ro = re.compile(r"pn=(.+) ") > r0=ro.match(s) > >>> print(r0.group(1)) > align upgrade > > > This is wrong. It should be

Re: Regular Expression bug?

2023-03-02 Thread Chris Angelico
On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote: > > Greetings. > > For the RegExp Gurus, consider the following python3 code: > > import re > s = "pn=align upgrade sd=2023-02-" > ro = re.compile(r"pn=(.+) ") > r0=ro.match(s) > >>> print(r0.group(1)) > align upgrade > > > This is wrong. I

Re: regular expression problem

2018-10-29 Thread Karsten Hilbert
On Mon, Oct 29, 2018 at 05:16:11PM +, MRAB wrote: > > Logically it should not because > > > > >s'::15>>$ > > > > does not match > > > > ::\d*>>$ > > > > but I am not sure how to tell it that :-) > > > For something like that, I'd use parsing by recursive descent. > > It might be

Re: regular expression problem

2018-10-29 Thread MRAB
On 2018-10-29 08:02, Karsten Hilbert wrote: On Sun, Oct 28, 2018 at 11:14:15PM +, MRAB wrote: > - lines can contain several placeholders > > - placeholders start and end with '$' > > - placeholders are parsed in three passes > > - the pass in which a placeholder is parsed is denoted by t

Re: regular expression problem

2018-10-29 Thread Karsten Hilbert
On Sun, Oct 28, 2018 at 11:57:48PM +0100, Brian Oney wrote: > On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote: > > [^<:] > > Would a simple regex work? This brought about the solution. However, not this way: > >>> import re > >>> t = '$$' > >>> re.findall('[^<>:$]+', t) > ['name', 'op

Re: regular expression problem

2018-10-29 Thread Karsten Hilbert
> Right, I am not trying to do that. I was, however, worried > that I need to make the expression not "trip over" fragments > of what might seem to constitute part of another placeholder. > > $<$::15>>$ > > Pass 1 might fill in to: > > $>$ > > and I was worried to make sure

Re: regular expression problem

2018-10-29 Thread Karsten Hilbert
On Mon, Oct 29, 2018 at 12:10:04AM +0100, Thomas Jollans wrote: > On 28/10/2018 22:04, Karsten Hilbert wrote: > > - options needs to be able to contain nearly anything, except '::' > > Including > and $ ? Unfortunately, it might. Even if I assume that earlier passes are "inside", and thusly "fil

Re: regular expression problem

2018-10-29 Thread Karsten Hilbert
On Sun, Oct 28, 2018 at 11:14:15PM +, MRAB wrote: > > - lines can contain several placeholders > > > > - placeholders start and end with '$' > > > > - placeholders are parsed in three passes > > > > - the pass in which a placeholder is parsed is denoted by the number of '<' > > and '>' nex

Re: regular expression problem

2018-10-28 Thread Thomas Jollans
On 28/10/2018 22:04, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' Including > and $ ? -- https://mail.python.org/mailman/listinfo/python-list

Re: regular expression problem

2018-10-28 Thread Thomas Jollans
On 28/10/2018 22:04, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' > > Is that sufficiently defined and helpful to design the regular expression ? so options isn't '.*', but more like '(:?[^:]+)*' (Figuring out what additional restriction this imposes

Re: regular expression problem

2018-10-28 Thread MRAB
On 2018-10-28 21:04, Karsten Hilbert wrote: On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote: Let my try to explain the expression I am actually after (assuming .compile with re.VERBOSE): rx_works = ' \$< # start of match is literal '$<' anywhere

Re: regular expression problem

2018-10-28 Thread Brian Oney via Python-list
On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote: > [^<:] Would a simple regex work? I mean: ~$ python Python 2.7.13 (default, Sep 26 2018, 18:42:22)  [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> t = '$$' >>> re.f

Re: regular expression problem

2018-10-28 Thread Karsten Hilbert
On Sun, Oct 28, 2018 at 10:04:39PM +0100, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' This seems to contradict the "nesting" requirement, but the nesting restriction "earlier parsing passes go inside" makes it possible. Karsten -- GPG 40BE 5B0E C

Re: regular expression problem

2018-10-28 Thread Karsten Hilbert
On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote: > Let my try to explain the expression I am actually after > (assuming .compile with re.VERBOSE): > > rx_works = ' > \$< # start of match is literal '$<' > anywhere inside string > [^<:]+?::

Re: regular expression problem

2018-10-28 Thread Karsten Hilbert
Now that MRAB has shown me the follies of my ways I would like to learn how to properly write the regular expression I need. This part: > rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$' > # it fails if switched around: > rx_fails = '\$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\

Re: regular expression problem

2018-10-28 Thread MRAB
On 2018-10-28 18:51, Karsten Hilbert wrote: Dear list members, I cannot figure out why my regular expression does not work as I expect it to: #--- #!/usr/bin/python from __future__ import print_function import re as regex rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?

Re: Regular expression

2017-07-26 Thread Jussi Piitulainen
Kunal Jamdade writes: > There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' . > > I want to extract the last 4 characters. I tried different regex. but > i am not getting it right. > > Can anyone suggest me how should i proceed.? os.path.splitext(name) # most likely; also: os.path

Re: Regular expression

2017-07-26 Thread Andre Müller
fname = 'first-324-True-rms-kjhg-Meterc639.html' # with string manipulation stem, suffix = fname.rsplit('.', 1) print(stem[-4:]) # oo-style with str manipulation import pathlib path = pathlib.Path(fname) print(path.stem[-4:]) -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expression

2017-07-26 Thread Peter Otten
Kunal Jamdade wrote: > There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' . > > I want to extract the last 4 characters. I tried different regex. but i am > not getting it right. > > Can anyone suggest me how should i proceed.? You don't need a regular expression: >>> import os

Re: Regular expression

2017-07-26 Thread Paul Barry
Is this what you are after? *>>> *data = 'first-324-True-rms-kjhg-Meterc639.html' *>>> *extension = data.find('.html') *>>> *extension 33 *>>> *data[extension-4:extension] 'c639' On 26 July 2017 at 13:00, Johann Spies wrote: > On 26 July 2017 at 13:52, Kunal Jamdade wrote: > > There is a

Re: Regular expression

2017-07-26 Thread Johann Spies
On 26 July 2017 at 13:52, Kunal Jamdade wrote: > There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' . > > I want to extract the last 4 characters. I tried different regex. but i am > not getting it right. > > Can anyone suggest me how should i proceed.? What have you tried? Why d

Re: Regular expression query

2017-03-12 Thread Vlastimil Brom
2017-03-12 17:22 GMT+01:00 : > Hi All, > > I have a string which looks like > > a,b,c "4873898374", d, ee "3343,23,23,5,,5,45", f > "5546,3434,345,34,34,5,34,543,7" > > It is comma saperated string, but some of the fields have a double quoted > string as part of it (and t

Re: Regular expression query

2017-03-12 Thread Tim Chase
On 2017-03-12 09:22, rahulra...@gmail.com wrote: > a,b,c "4873898374", d, ee "3343,23,23,5,,5,45", > f "5546,3434,345,34,34,5,34,543,7" > > It is comma saperated string, but some of the fields have a double > quoted string as part of it (and that double quoted string can ha

Re: Regular expression query

2017-03-12 Thread Jussi Piitulainen
rahulra...@gmail.com writes: > Hi All, > > I have a string which looks like > > a,b,c "4873898374", d, ee "3343,23,23,5,,5,45", f > "5546,3434,345,34,34,5,34,543,7" > > It is comma saperated string, but some of the fields have a double > quoted string as part of it (and th

Re: Regular expression query

2017-03-12 Thread Larry Martell
On Sun, Mar 12, 2017 at 12:22 PM, wrote: > Hi All, > > I have a string which looks like > > a,b,c "4873898374", d, ee "3343,23,23,5,,5,45", f > "5546,3434,345,34,34,5,34,543,7" > > It is comma saperated string, but some of the fields have a double quoted > string as part

Re: Regular expression and substitution, unexpected duplication

2015-08-19 Thread Laurent Pointal
MRAB wrote: > On 2015-08-18 22:42, Laurent Pointal wrote: >> Hello, >> ellipfind_re = re.compile(r"((?=\.\.\.)|…)", re.IGNORECASE|re.VERBOSE) >> ellipfind_re.sub(' ... ', >> "C'est un essai... avec différents caractères… pour voir.") > (?=...) is a lookahead; a non-capture group is (?:..

Re: Regular expression and substitution, unexpected duplication

2015-08-18 Thread MRAB
On 2015-08-18 22:42, Laurent Pointal wrote: Hello, I want to make a replacement in a string, to ensure that ellipsis are surrounded by spaces (this is not a typographycal problem, but a preparation for late text chunking). I tried with regular expressions and the SRE_Pattern.sub() method, but I

Re: Regular Expression

2015-06-04 Thread Laura Creighton
In a message of Thu, 04 Jun 2015 06:36:29 -0700, Palpandi writes: >Hi All, > >This is the case. To split "string2" from "string1_string2" I am using >re.split('_', "string1_string2", 1) And you shouldn't be. The 3rd argument, 1 says stop after one match. >It is working fine for string "string1_

Re: Regular Expression

2015-06-04 Thread Peter Otten
Palpandi wrote: > This is the case. To split "string2" from "string1_string2" I am using > re.split('_', "string1_string2", 1)[1]. > > It is working fine for string "string1_string2" and output as "string2". > But actually the problem is that if a sting is "__string1_string2" and the > output is

Re: Regular Expression

2015-06-04 Thread Tim Chase
On 2015-06-04 06:36, Palpandi wrote: > This is the case. To split "string2" from "string1_string2" I am > using re.split('_', "string1_string2", 1)[1]. > > It is working fine for string "string1_string2" and output as > "string2". But actually the problem is that if a sting is > "__string1_string2

Re: Regular Expression

2015-06-04 Thread Steven D'Aprano
On Thu, 4 Jun 2015 11:36 pm, Palpandi wrote: > Hi All, > > This is the case. To split "string2" from "string1_string2" I am using > re.split('_', "string1_string2", 1)[1]. There is absolutely no need to use the nuclear-powered bulldozer of regular expressions to crack that tiny peanut. Strings

Re: Regular Expression

2015-06-04 Thread Larry Martell
On Thu, Jun 4, 2015 at 9:36 AM, Palpandi wrote: > > Hi All, > > This is the case. To split "string2" from "string1_string2" I am using > re.split('_', "string1_string2", 1)[1]. > > It is working fine for string "string1_string2" and output as "string2". But > actually the problem is that if a sti

Re: Regular Expression

2015-04-12 Thread Pippo
I fixed all! Thanks. This is the result: #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health car

Re: Regular Expression

2015-04-12 Thread Pippo
Sweet! Thanks all of you! I matched everything except these ones... trying to find the best way > whether #C[oral | (recorded in (any form | medium))], that #C[the past, present, or future physical | mental health | condition of an individual] | > #C[the past, present, or future payment fo

Re: Regular Expression

2015-04-12 Thread Pippo
> Put the print inside the "if"; you don't really care when result is None, and > anyway you can't access .group when it is None - it is not an 're.match" > object, because there was no match. Thanks Cameron, this worked. > > Once you're happy you should consider what happens when there is m

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 18:28, Pippo wrote: On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: [...] Pippo, please take a moment to trim the less relevant verbiage from the quoted material; it makes replies easier to read because what is left can be taken to be more "on point". Thanks.

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: > On 12Apr2015 17:55, Pippo wrote: > >On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> It looks like it should, unless you have mangled your regular expression. > [...] > >> Also note that you can print the reg

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: It looks like it should, unless you have mangled your regular expression. [...] Also note that you can print the regexp's .pattern attribute: print(constraint.pattern) as a check that what was

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 21:07:09 UTC-4, MRAB wrote: > On 2015-04-13 01:55, Pippo wrote: > > On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >>

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: >> >> > > constraint = re.compile(r'(#C\[\w*\]')) >> >> > > result = constraint.search(content[j],re.MULTILINE) >> >> > > text.append(result) >> >> > > print(text) [...] >> >> r

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:25, Pippo wrote: On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: On 2015-04-13 00:47, Pippo wrote: > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: >> On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: >> > On 2015-04-12 23:49, Pippo wrote: >> > > I have a text

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >> > > text.append(result) > >> >> > > print(text) > [...] > >> >> result is empty! Although

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:25, Pippo wrote: >> > > constraint = re.compile(r'(#C\[\w*\]')) >> > > result = constraint.search(content[j],re.MULTILINE) >> > > text.append(result) >> > > print(text) [...] >> result is empty! Although it should have a content. [...] > I fixed the syntax

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: > On 2015-04-13 00:47, Pippo wrote: > > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > >> On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > >> > On 2015-04-12 23:49, Pippo wrote: > >> > > I have a text as follows: > >> > > > >> >

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 00:47, Pippo wrote: On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > On 2015-04-12 23:49, Pippo wrote: > > I have a text as follows: > > > > "#D{#C[Health] #P[Information] - > > means any information, including #ST[genet

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:47:09 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > > On 2015-04-12 23:49, Pippo wrote: > > > > I have a text as follows: > > > > > > > > "#D{#C[Health] #P[Information] - > > >

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > On 2015-04-12 23:49, Pippo wrote: > > > I have a text as follows: > > > > > > "#D{#C[Health] #P[Information] - > > > means any information, including #ST[genetic information], > > > wh

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > On 2015-04-12 23:49, Pippo wrote: > > I have a text as follows: > > > > "#D{#C[Health] #P[Information] - > > means any information, including #ST[genetic information], > > whether #C[oral | (recorded in (any form | medium))], that > > (1)#C[Is

Re: Regular Expression

2015-04-12 Thread Ben Finney
Pippo writes: > I try with regex but it doesn't work: Thank you for providing a short, self-contained example. What does this code do when you try? If there is an error, please post the full traceback exactly (cut and paste the traceback text). What are you expecting it to do, and how is that

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-12 23:49, Pippo wrote: I have a text as follows: "#D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public hea

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Mark Lawrence
On 27/05/2014 12:39, Aman Kashyap wrote: On Tuesday, 27 May 2014 16:59:38 UTC+5:30, Daniel wrote: What about skipping the re and try this: 'start=|ID=ter54rt543d|SID=ter54rt543d|end=|'.split('|')[1][3:] On 27.05.2014 14:09, Vlastimil Brom wrote: 2014-05-27 12:59 GMT+02:00 Aman Kashyap :

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Roy Smith
In article , Wolfgang Maier wrote: > On 27.05.2014 13:39, Aman Kashyap wrote: > >> On 27.05.2014 14:09, Vlastimil Brom wrote: > >> > >>> you can just escpape the pipe with backlash like any other metacharacter: > >>> > >>> r"start=\|ID=ter54rt543d" > >>> > >>> be sure to use the raw string notat

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Wolfgang Maier
On 27.05.2014 13:39, Aman Kashyap wrote: On 27.05.2014 14:09, Vlastimil Brom wrote: you can just escpape the pipe with backlash like any other metacharacter: r"start=\|ID=ter54rt543d" be sure to use the raw string notation r"...", or you can double all backslashes in the string. Thanks

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Aman Kashyap
On Tuesday, 27 May 2014 16:59:38 UTC+5:30, Daniel wrote: > What about skipping the re and try this: > > > > 'start=|ID=ter54rt543d|SID=ter54rt543d|end=|'.split('|')[1][3:] > > > > On 27.05.2014 14:09, Vlastimil Brom wrote: > > > 2014-05-27 12:59 GMT+02:00 Aman Kashyap : > > >> I would like

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Daniel
What about skipping the re and try this: 'start=|ID=ter54rt543d|SID=ter54rt543d|end=|'.split('|')[1][3:] On 27.05.2014 14:09, Vlastimil Brom wrote: 2014-05-27 12:59 GMT+02:00 Aman Kashyap : I would like to create a regular expression in which i can match the "|" special character too. e.g.

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Aman Kashyap
On Tuesday, 27 May 2014 16:39:19 UTC+5:30, Vlastimil Brom wrote: > 2014-05-27 12:59 GMT+02:00 Aman Kashyap : > > > I would like to create a regular expression in which i can match the "|" > > special character too. > > > > > > e.g. > > > > > > start=|ID=ter54rt543d|SID=ter54rt543d|end=| > >

Re: Regular Expression for the special character "|" pipe

2014-05-27 Thread Vlastimil Brom
2014-05-27 12:59 GMT+02:00 Aman Kashyap : > I would like to create a regular expression in which i can match the "|" > special character too. > > e.g. > > start=|ID=ter54rt543d|SID=ter54rt543d|end=| > > I want to only |ID=ter54rt543d| from the above string but i am unable to > write the pattern

RE: Regular Expression : Bad Character Range

2013-12-19 Thread Frank Cui
should have escaped hyphen as it could be used for ranging. sorry for the bother... From: y...@outlook.com To: python-list@python.org Subject: Regular Expression : Bad Character Range Date: Thu, 19 Dec 2013 23:50:52 -0300 Hey guys, I'm trying to compile a regular Expression while encounteri

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
Huh, did not realize that endswith takes a list. I'll remember that in the future. This need is actually for http://schemaspy.sourceforge.net/, which allows one to include only tables/views that match a pattern. Either there is a bug in Schemaspy's code or Java's implementation of regular expres

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
> Huh, did not realize that endswith takes a list. I'll remember that in > the future. > > This need is actually for http://schemaspy.sourceforge.net/, which allows > one to include only tables/views that match a pattern. > > Either there is a bug in Schemaspy's code or Java's implementation of >

Re: Regular expression negative look-ahead

2013-07-02 Thread Neil Cerutti
On 2013-07-01, Jason Friedman wrote: > > I have table names in this form: > MY_TABLE > MY_TABLE_CTL > MY_TABLE_DEL > MY_TABLE_RUN > YOUR_TABLE > YOUR_TABLE_CTL > YOUR_TABLE_DEL > YOUR_TABLE_RUN > > I am trying to create a regular expression that will return true for only > these tables: > MY_TABLE

Re: Regular expression negative look-ahead

2013-07-01 Thread Ian Kelly
On Mon, Jul 1, 2013 at 8:27 PM, Jason Friedman wrote: > Found this: > http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python. > > This pattern seems to work: > pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") > > But I am not sure why. > > > On Mon, Jul 1, 2013

Re: Regular expression negative look-ahead

2013-07-01 Thread Jason Friedman
Found this: http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python . This pattern seems to work: pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") But I am not sure why. On Mon, Jul 1, 2013 at 5:07 PM, Jason Friedman wrote: > I have table names in this form

Re: Regular expression problem

2013-03-11 Thread Terry Reedy
On 3/11/2013 2:30 PM, Serhiy Storchaka wrote: On 11.03.13 04:06, Terry Reedy wrote: On 3/10/2013 1:42 PM, mukesh tiwari wrote: Hello all I am trying to solve this problem[1] [1] http://www.spoj.com/problems/MAIN12C/ As I remember, and as it still appears, this site severely penalizes Python s

Re: Regular expression problem

2013-03-11 Thread Serhiy Storchaka
On 11.03.13 04:06, Terry Reedy wrote: On 3/10/2013 1:42 PM, mukesh tiwari wrote: Hello all I am trying to solve this problem[1] [1] http://www.spoj.com/problems/MAIN12C/ As I remember, and as it still appears, this site severely penalizes Python solvers by using the same time limit for all lan

Re: Regular expression problem

2013-03-11 Thread rusi
On Mar 11, 2:28 pm, jmfauth wrote: > On 11 mar, 03:06, Terry Reedy wrote: > > > > > ... > > By teaching 'speed before correctness", this site promotes bad > > programming habits and thinking (and the use of low-level but faster > > languages). > > ... > > This is exactly what "your" flexible stri

Re: Regular expression problem

2013-03-11 Thread Mark Lawrence
On 11/03/2013 09:28, jmfauth wrote: On 11 mar, 03:06, Terry Reedy wrote: ... By teaching 'speed before correctness", this site promotes bad programming habits and thinking (and the use of low-level but faster languages). ... This is exactly what "your" flexible string representation does!

Re: Regular expression problem

2013-03-11 Thread jmfauth
On 11 mar, 03:06, Terry Reedy wrote: > > ... > By teaching 'speed before correctness", this site promotes bad > programming habits and thinking (and the use of low-level but faster > languages). > ... This is exactly what "your" flexible string representation does! And away from technical aspe

Re: Regular expression problem

2013-03-10 Thread Terry Reedy
On 3/10/2013 1:42 PM, mukesh tiwari wrote: Hello all I am trying to solve this problem[1] [1] http://www.spoj.com/problems/MAIN12C/ As I remember, and as it still appears, this site severely penalizes Python solvers by using the same time limit for all languages. Thus, a 'slow' python program

Re: Regular expression problem

2013-03-10 Thread Chris Angelico
On Mon, Mar 11, 2013 at 5:48 AM, mukesh tiwari wrote: > Hi Chris > Thank you! Now I am getting wrong answer so at least program is faster then > previous one and I am looking for wrong answer reason. Thanks again! Excellent! Have fun. Incidentally, regular expressions aren't the only way to sol

Re: Regular expression problem

2013-03-10 Thread mukesh tiwari
Hi Chris Thank you! Now I am getting wrong answer so at least program is faster then previous one and I am looking for wrong answer reason. Thanks again! import re if __name__ == "__main__": n = int ( raw_input() ) c = 1 while c <= n : email = filter ( lambda x : x != None ,

Re: Regular expression problem

2013-03-10 Thread mukesh tiwari
Hi Chris On the problem page, it is 3 second. > What is the time limit? I just tried it (Python 2.6 under Windows) and > > it finished in a humanly-immeasurable amount of time. Are you sure > > that STDIN (eg raw_input()) is where your test data is coming from? Yes, on SPOJ we read data from

Re: Regular expression problem

2013-03-10 Thread Chris Angelico
On Mon, Mar 11, 2013 at 4:59 AM, Chris Angelico wrote: > On Mon, Mar 11, 2013 at 4:42 AM, mukesh tiwari > wrote: >> I am trying to solve this problem[1] using regular expression. I wrote this >> code but I am getting time limit exceed. Could some one please tell me how >> to make this code run

Re: Regular expression problem

2013-03-10 Thread Chris Angelico
On Mon, Mar 11, 2013 at 4:42 AM, mukesh tiwari wrote: > I am trying to solve this problem[1] using regular expression. I wrote this > code but I am getting time limit exceed. Could some one please tell me how to > make this code run faster. What is the time limit? I just tried it (Python 2.6 un

Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 01:45:58 -0800, iMath wrote: > 在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道: >> I only know the dollar sign ($) will match a pattern from the >> >> end of a string,but which method does it work with ,re.match() or >> re.search() ? > > I thought re.match('h.$', 'hbxihi') will matc

Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2013-01-07 Thread iMath
在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道: > I only know the dollar sign ($) will match a pattern from the > > end of a string,but which method does it work with ,re.match() or re.search() > ? I thought re.match('h.$', 'hbxihi') will match ‘hi’ ,but it does not .so why ? -- http://mail.python.or

Re: Regular expression syntax, was Re: pylint, was Re: pygame - importing GL - very bad...

2013-01-04 Thread someone
On 01/03/2013 12:39 PM, Peter Otten wrote: someone wrote: On 01/03/2013 10:00 AM, Peter Otten wrote: Terry Reedy wrote: [a-z_][a-z0-9_]{2,30}$) - so I suppose it wants this name to end with [an underscore ? No, it allows underscores. As I read that re, 'rx', etc, do match. They No, it's

Re: Regular expression for different date formats in Python

2012-11-26 Thread Miki Tebeka
On Monday, November 26, 2012 8:34:22 AM UTC-8, Michael Torrie wrote: > http://pypi.python.org/pypi/python-dateutil > ... > I don't believe the library is updated for Python 3 yet, sadly. dateutil supports 3.x since version 2.0. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression for different date formats in Python

2012-11-26 Thread Michael Torrie
On 11/26/2012 06:15 AM, undesputed.hack...@gmail.com wrote: > I am a beginner in python and need help with writing a regular > expression for date and time to be fetched from some html documents. Would the "parser" module from the third-party dateutil module work for you? http://pypi.python.org/p

Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2012-09-28 Thread Ian Kelly
On Fri, Sep 28, 2012 at 12:07 PM, Prasad, Ramit wrote: > I guess you can consider re.match's pattern to be > prefixed with '^'. You can in this case, but they're not equivalent in multi-line mode: >>> re.match('^two', 'one\ntwo', re.M) >>> re.search('^two', 'one\ntwo', re.M) <_sre.SRE_Match obje

RE: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2012-09-28 Thread Prasad, Ramit
iMath wrote: > Sent: Wednesday, September 26, 2012 2:39 AM > To: python-list@python.org > Subject: regular expression : the dollar sign ($) work with re.match() or > re.search() ? > > I only know the dollar sign ($) will match a pattern from the > end of a string,but which method does it work wi

Re: regular expression : the dollar sign ($) work with re.match() or re.search()

2012-09-26 Thread Jussi Piitulainen
Alister writes: > On Wed, 26 Sep 2012 10:48:00 +0300, Jussi Piitulainen wrote: > > > iMath writes: > > > >> I only know the dollar sign ($) will match a pattern from the end > >> of a string, but which method does it work with, re.match() or > >> re.search() > > > > It works with both. With re.m

Re: regular expression : the dollar sign ($) work with re.match() or re.search()

2012-09-26 Thread Alister
On Wed, 26 Sep 2012 10:48:00 +0300, Jussi Piitulainen wrote: > iMath writes: > >> I only know the dollar sign ($) will match a pattern from the end of a >> string, but which method does it work with, re.match() or re.search() > > It works with both. With re.match, the pattern has to match at the

Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2012-09-26 Thread Peter Otten
iMath wrote: > I only know the dollar sign ($) will match a pattern from the > end of a string,but which method does it work with ,re.match() or > re.search() ? Why not try it out in the interactive interpreter? Here's the "deluxe version": >>> def demo(pattern="mid$", texts=["start mid end",

Re: regular expression : the dollar sign ($) work with re.match() or re.search()

2012-09-26 Thread Chris Angelico
On Wed, Sep 26, 2012 at 5:48 PM, Jussi Piitulainen wrote: > What was the weird character that you used as a question mark? I > removed them because they confuse the newsreader I use. It appears to be Unicode Character 'FULLWIDTH QUESTION MARK' (U+FF1F). Normally I'd be inclined to simply use U+00

Re: regular expression : the dollar sign ($) work with re.match() or re.search()

2012-09-26 Thread Jussi Piitulainen
iMath writes: > I only know the dollar sign ($) will match a pattern from the end of > a string, but which method does it work with, re.match() or > re.search() It works with both. With re.match, the pattern has to match at the start of the string _and_ the $ has to match the end of the string (o

Re: Regular expression : non capturing groups are faster ?

2012-01-03 Thread Devin Jeanpierre
s '(?:a)*) Also, wouldn't say "very fast". Compare those two groups with 'a*'. I'm not sure what's going on there. -- Devin On Tue, Jan 3, 2012 at 3:07 PM, Octavian Rasnita wrote: > From: "Devin Jeanpierre" > Subject: Re: Regul

Re: Regular expression : non capturing groups are faster ?

2012-01-03 Thread Octavian Rasnita
From: "Devin Jeanpierre" Subject: Re: Regular expression : non capturing groups are faster ? >> You meant Perl Documentation, didn't you ? > > I guess that works too. I did mean Python, though -- its intent is to > say "you shouldn't worry about this&q

Re: Regular expression : non capturing groups are faster ?

2012-01-03 Thread Devin Jeanpierre
> You meant Perl Documentation, didn't you ? I guess that works too. I did mean Python, though -- its intent is to say "you shouldn't worry about this", but in the process it says "this does not exist" (a lie). "slightly better performance" would be accurate, as said by Goyvaerts/ -- Devin On T

Re: Regular expression : non capturing groups are faster ?

2012-01-03 Thread candide
Le 03/01/2012 12:56, Devin Jeanpierre a écrit : The second assertion sounds more likely. It seems very odd that Python and Perl implementations are divergent on this point. Any opinion ? The Python documentation oversimplifies. You meant Perl Documentation, didn't you ? It's a commun opinio

  1   2   3   4   5   6   >