Re: problem with regex

2014-04-28 Thread Roy Smith
In article , dimm...@gmail.com wrote: > i want to find a specific urls from a txt file but i have some issus. First > when i take just two lines from the file with copy paste and assign it to a > variable like this and it works only with triple quotes > > test='' [...] > but if a take tho

problem with regex

2014-04-28 Thread dimmaim
i want to find a specific urls from a txt file but i have some issus. First when i take just two lines from the file with copy paste and assign it to a variable like this and it works only with triple quotes test='''_*_n.jpg","timelineCoverPhoto":"{\"focus\":{\"x\":0.5,\"y\":0.386925795053},\"p

problem with regex

2014-04-28 Thread dimmaim
i want to find a specific urls from a txt file but i have some issus. First when i take just two lines from the file with copy paste and assign it to a variable like this and it works only with triple quotes test='''_*_n.jpg","timelineCoverPhoto":"{\"focus\":{\"x\":0.5,\"y\":0.386925795053},\"p

Re: problem with regex, how to conclude more than one character

2008-11-07 Thread tecspring
On Nov 7, 3:13 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Thu, Nov 6, 2008 at 11:06 PM,  <[EMAIL PROTECTED]> wrote: > > I always have no idea about how to express "conclude the entire word" > > with regexp,  while using python, I encountered this problem again... > > > for example, if I wan

Re: problem with regex, how to conclude more than one character

2008-11-06 Thread Charles Yan
Really thanks for quickly reply Chris! Actually I tried BeautifulSoup and it's great. But I'm not very familiar with it and it need more codes to parse the html and get the right text. I think regexp is more convenient if there is a way to filter out the list just in one line:) I did this all the w

Re: problem with regex, how to conclude more than one character

2008-11-06 Thread Chris Rebert
On Thu, Nov 6, 2008 at 11:06 PM, <[EMAIL PROTECTED]> wrote: > I always have no idea about how to express "conclude the entire word" > with regexp, while using python, I encountered this problem again... > > for example, if I want to match the "string" in "test a string", > re.findall(r"[^a]* (\w+

Re: problem with regex, how to conclude more than one character

2008-11-06 Thread tecspring
On Nov 7, 3:06 pm, [EMAIL PROTECTED] wrote: > I always have no idea about how to express "conclude the entire word" > with regexp,  while using python, I encountered this problem again... > > for example, if I want to match the "string" in "test a string", > re.findall(r"[^a]* (\w+)","test a string

problem with regex, how to conclude more than one character

2008-11-06 Thread tecspring
I always have no idea about how to express "conclude the entire word" with regexp, while using python, I encountered this problem again... for example, if I want to match the "string" in "test a string", re.findall(r"[^a]* (\w+)","test a string") will work, but what if there is not "a" but "an"(t

Re: problem with regex

2006-07-28 Thread Rob Wolfe
abcd wrote: > not sure why this passes: > > > >>> regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*' > >>> p = re.compile(regex) > >>> p.match('c:\\test') > <_sre.SRE_Match object at 0x009D77E0> > >>> p.match('c:\\test?:/') > <_sre.SRE_Match object at 0x009D7720> > >>> > > the last example shouldnt give a ma

Re: problem with regex

2006-07-28 Thread Tim Chase
regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*' p = re.compile(regex) p.match('c:\\test') > <_sre.SRE_Match object at 0x009D77E0> p.match('c:\\test?:/') > <_sre.SRE_Match object at 0x009D7720> > > the last example shouldnt give a match Ah, but it should, because it *does* match. >>>

Re: problem with regex

2006-07-28 Thread abcd
not sure why this passes: >>> regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*' >>> p = re.compile(regex) >>> p.match('c:\\test') <_sre.SRE_Match object at 0x009D77E0> >>> p.match('c:\\test?:/') <_sre.SRE_Match object at 0x009D7720> >>> the last example shouldnt give a match -- http://mail.python.org/ma

Re: problem with regex

2006-07-28 Thread abcd
Sybren Stuvel wrote: > Yes, because after the "c:" you expect a backslash, and not a tab > character. Read the manual again about raw strings and character > escaping, it'll do you good. doh. i shall do that. thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with regex

2006-07-28 Thread abcd
sorry i forgot to escape the question mark... > [code] > import re > p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*') even when I escape that it still doesnt work as expected. p = re.compile(r'[A-Za-z]:\\([^/:\*\?"<>\|])*') p.match('c:\test') still returns None. -- http://mail.python.org/mailm

Re: problem with regex

2006-07-28 Thread Tim Chase
> p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*') > > x = p.match("c:\test") > any ideas why? i escape the back-slash, the asterisk *, and the PIPE | > b/c they are regex special characters. Same problem, only now in the other string: >>> s = "c:\test" >>> print s c: est Your "\t"

Re: problem with regex

2006-07-28 Thread abcd
well thanks for the quick replies, but now my regex doesn't work. [code] import re p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*') x = p.match("c:\test") [/code] x is None any ideas why? i escape the back-slash, the asterisk *, and the PIPE | b/c they are regex special characters. -- http

Re: problem with regex

2006-07-28 Thread Tim Chase
> when I do, re.compile('[A-Za-z]:\\([^/:\*\?"<>\|])*') ...I get > > sre_constants.error: unbalanced parenthesis Because you're not using raw strings, the escapables become escaped, making your regexp something like [A-Za-z]:\([^/:\*\?"<>\|])* (because it knows what "\\" is, but likel

Re: problem with regex

2006-07-28 Thread Rob Wolfe
abcd wrote: > I have a regex: '[A-Za-z]:\\([^/:\*\?"<>\|])*' > > when I do, re.compile('[A-Za-z]:\\([^/:\*\?"<>\|])*') ...I get > > sre_constants.error: unbalanced parenthesis > > do i need to escape something else? i see that i have matching > parenthesis. You should use raw string: re.compile

Re: problem with regex

2006-07-28 Thread Barry
On 28 Jul 2006 05:45:05 -0700, abcd <[EMAIL PROTECTED]> wrote: > I have a regex: '[A-Za-z]:\\([^/:\*\?"<>\|])*' > > when I do, re.compile('[A-Za-z]:\\([^/:\*\?"<>\|])*') ...I get > > sre_constants.error: unbalanced parenthesis > > do i need to escape something else? i see that i have matching > pa

problem with regex

2006-07-28 Thread abcd
I have a regex: '[A-Za-z]:\\([^/:\*\?"<>\|])*' when I do, re.compile('[A-Za-z]:\\([^/:\*\?"<>\|])*') ...I get sre_constants.error: unbalanced parenthesis do i need to escape something else? i see that i have matching parenthesis. thx -- http://mail.python.org/mailman/listinfo/python-list