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*?>\$|\$<[^<:]+?
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*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$'
# it fails if switched arou
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
A friendly reminder that this forum is for general discussion and
questions about Python.
"Pretty much anything Python-related is fair game for discussion, and
the group is even fairly tolerant of off-topic digressions; there have
been entertaining discussions of topics such as floating point,
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
Hello all
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.
import re
if __name__ == "__main__":
n = int ( raw_input() )
c = 1
while c <= n :
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\
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\xce\xb3_\x10\xcc\x8d\xe2\x10\xc8\x00\xa4\x10\xc
> > I want to use django to dispatch url.
> > The url is like /test/Google/6,and my patten is r'^/test/(?P\b\W+
\W should be \w, a typo? :)
> > \b)/(?P\d+)$'.
> > It works when the string is English(like Google), but fails when the
> > string is in foreign language.
Try this:
r'(?u)^/test/(?P\b\w+\
lookon a écrit :
I want to use django to dispatch url.
The url is like /test/Google/6,and my patten is r'^/test/(?P\b\W+
\b)/(?P\d+)$'.
It works when the string is English(like Google), but fails when the
string is in foreign language.
Care to give an exemple of url that fails ?
Anyway, if you
>
>
>
>
> -- Forwarded message --
> From: lookon <[EMAIL PROTECTED]>
> To: python-list@python.org
> Date: Fri, 10 Oct 2008 03:58:08 -0700 (PDT)
> Subject: a regular expression problem
> I want to use django to dispatch url.
> The url is like /
I want to use django to dispatch url.
The url is like /test/Google/6,and my patten is r'^/test/(?P\b\W+
\b)/(?P\d+)$'.
It works when the string is English(like Google), but fails when the
string is in foreign language.
Can anyone tell me the righ regular expression?
Thank you!
--
http://mail.pyth
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
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 next12M 48S
And I need to get the remaining time. Until here, isn't a problem
getting it, but if the remaining time is less than 60 seconds then the
source
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:
'Som
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 = """
\n\n28996\n\n\n28997\n"""
regex = re.compile(r'', re.S)
L = regex.findall(s)
print L
> ['o
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 = """
\n\n28996\n\n\n28997\n"""
regex = re.compile(r'', re.S)
L = regex.findall(s)
print L
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, duikboot
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 = """
> >>>\n\n28996\n\n\n28997\n"""
> >>> regex = re.compile(r'', re.S)
>
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'', re.S)
>
> Note, there is now a question mark (?) after the .*
>
> By default, regular
You just need a one-character addition to your regex:
regex = re.compile(r'', 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 was
grabbing everything bet
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 = """
>>>\n\n28996\n\n\n28997\n"""
>>> regex = re.compile(r'', re.S)
>>> L = regex.findall(s)
>>> print L
['organisatie>\n28996\n
\n\n28997\n\n2
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
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?
Thx
John.
=
--
http://mail.python.org/mailman/listinfo/python-list
>
> 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
(I don't know if it is the right place. So if I am wrong, please point
me the right direction.
If this post is read by you masters, I'm honoured. If I am getting a
mere response, I'm blessed!)
Hi,
I'm a newbie regular expression user. I use regex in my Python
programs. I have a strange
(sometim
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
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,a3,a3,...,a7,a8,...,a12,a13,...]
or b=[
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
1 December 2004 12:23
To: [EMAIL PROTECTED]
Subject: Regular Expression Problem...
Hello NG,
I am quite new with Python... I'm writing an application that does
also some regexp things on strings, but I'm having problem about
identifying/extracting a substring from another string
[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
Hello NG,
I am quite new with Python... I'm writing an application that does
also some regexp things on strings, but I'm having problem about
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
64 matches
Mail list logo