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
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
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
> 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
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
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
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
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
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
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
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
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
> [^<:]+?::
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+>\$|\$<[^<:]+?::.*?::\
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*?>\$|\$<[^<:]+?
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
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
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
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!
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
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
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
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 ,
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
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
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
On Tue, 08 Sep 2009 09:21:35 +, §äŽmÅ Ãâ¬vªº...@â¬Ã¹â¬Ã wrote:
> I have the following source code
>
>
> import re
> d = 'RTCB\r\nsignature:\xf1\x11
> \xde\x10\xfe\x0f\x9c\x10\xf6\xc9_\x10\xf3\xeb<\x10\xf2Zt\x10\xef\xd2\x91
\x10\xe6\xe7\xfb\x10\xe5p\x99\x10\x
2009/9/8 æ¾å°èªå·±çä¸ç天 :
> I have the following source code
>
>
> import re
> d = 'RTCB\r\nsignature:\xf1\x11
> \xde\x10\xfe\x0f\x9c\x10\xf6\xc9_\x10\xf3\xeb<\x10\xf2Zt\x10\xef\xd2\x91\x10\xe6\xe7\xfb\x10\xe5p\x99\x10\xe2\x1e\xdf\x10\xdb\x0e\x9f\x10\xd8p\x06\x10\
On Jun 22, 10:13 pm, abranches <[EMAIL PROTECTED]> wrote:
> Hello everyone.
>
> I'm having a problem when extracting data from HTML with regular
> expressions.
> This is the source code:
>
> You are ready in the next style="display: inline;">12 span>M 48S
>
> And I need to get the remaining time. U
En Mon, 30 Apr 2007 19:16:58 -0300, John Davis <[EMAIL PROTECTED]>
escribió:
> Hi all,
> I have a large logged string "str". I would like to strip down "str" so
> that
> it contains only the lines that have "ERROR" in them. Could somebody
> give me
> and indication of how to do this?
Forget
>
> Less is more:
>
> pat = re.compile(r'href="([^"]+)')
> pat.search(your_link)
>
>
Be sure to also catch:
And it's not certain whether the OP is interested in tags like:
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
On 13 Jul 2006 23:12:05 -0700, Paul McGuire <[EMAIL PROTECTED]> wrote:
Pyparsing is also good for recognizing basic HTML tags and theirattributes, regardless of the order of the attributes.-- PaultestText = """sldkjflsa;fajhere it would be 'mystylesheet.css'. I used the following regex to getthis v
Pyparsing is also good for recognizing basic HTML tags and their
attributes, regardless of the order of the attributes.
-- Paul
testText = """sldkjflsa;faj
here it would be 'mystylesheet.css'. I used the following regex to get
this value(I dont know if it
I thought I was doing fine until I go
> So What should I do to get the exact value(here the value after
> 'href=') in any case even if the
>
> tags are like these? >>
>
>
> -OR-
>
> -OR-
>
The following should do it:
expr = r'http://mail.python.org/mailman/listinfo/python-list
Justin Azoff wrote:
> >>> from BeautifulSoup import BeautifulSoup
> >>> html=''
> >>> page=BeautifulSoup(html)
> >>> page.link.get('href')
> 'mystylesheet.css'
On second thought, you will probably want something like
>>> [link.get('href') for link in page.fetch('link',{'type':'text/css'})]
['myst
John Blogger wrote:
> That I want a particular tag value of one of my HTML files.
>
> ie: I want only the value after 'href=' in the tag >>
>
> ''
>
> here it would be 'mystylesheet.css'. I used the following regex to get
> this value(I dont know if it is good).
No matter how good it is you should
Hey,
I'm new with regex's as well but here is my idea. Since you don't know
which attribute will come first why don't structure your regex like
this
(first off, I'll assume that \s == ' ', actually now that I think of
it, isn't \s any whitespace character? anyways \s == ' ' for now)
''
I think
thank you again:
i used list and not set because order in my list is important.
in fact i'd like to apply this function to strings (or ordered
sequences of data).
For this reason proposed to use regular expression.
best regards.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> hi everyone
> there is a way, using re, to test (for es) in
> a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is
> composed by three "sublists" of a separated or not by elements.
>
> if b=[a2,a3,a4,a7,a8,a12,a13] gives true because in a
> we have [,a2,
[EMAIL PROTECTED] wrote:
> hi everyone
> there is a way, using re, to test (for es) in
> a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is
> composed by three "sublists" of a separated or not by elements.
Heya,
Is there any particular reason why you need to use re?
If you're usin
Obviously, Peter and Jorge are hardcore, but below is what a beginner like
me hacked up:
My point, I guess, is that it is possible to quickly get a solution to a
specific problem like this without being a total expert. The code below
was typed out once, and with only one minor correction be
[EMAIL PROTECTED] wrote:
> identifying/extracting a substring from another string. What I have to do
> is to extract all the strings that begins with a "$" character, but
> excluding characters like "." (point) and "'" (single quote) and "\" "/"
> (slashes). For example I have:
>
> 1) This Is An
You could try the following:
regex = re.compile("[\$]\w+", re.IGNORECASE)
I've only done a bit of testing. Maybe somebody has a better solution.
Cheers!!
Dermot.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 01 December 2004
[EMAIL PROTECTED] writes:
> #CODE BEGIN
> import re
>
> mystring = "This Is An \$EXAMPLE\String;"
> regex = re.compile("[\$]+\S*",re.IGNORECASE)
> keys = regex.findall(mystring)
>
> #CODE END
regex = re.compile("[\$]+\w*",re.IGNORECASE)
>>> import re
>>>
>>> mystring = "This Is An \$EXAMPLE\Stri
43 matches
Mail list logo