Re: I need help with this python regex

2018-04-28 Thread Peter J. Holzer
On 2018-04-27 21:04:49 -0700, Ed Manning wrote: > Here is the source code. > > > import re > > > log = open("csg.txt", "r") # Opens a file call session.txt > regex = re.compile(r'policy id \d+') # search for the policy ID > regex1 = re.compile(r'log count \d+') # search for the policy ID > > f

I need help with this python regex

2018-04-27 Thread Ed Manning
Here is the source code. import re log = open("csg.txt", "r") # Opens a file call session.txt regex = re.compile(r'policy id \d+') # search for the policy ID regex1 = re.compile(r'log count \d+') # search for the policy ID for match in log: x = regex.findall(match) y = regex1.findall(m

RE: Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of MRAB Sent: Friday, April 13, 2018 12:05 PM To: python-list@python.org Subject: Re: Python regex pattern from array of hex chars > Use re.escape: > > regex = re.compile('[^{}]+'.format(re.escape(''.join

Re: Python regex pattern from array of hex chars

2018-04-13 Thread MRAB
On 2018-04-13 18:28, Joseph L. Casale wrote: I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in character_class))) I would use th

Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in character_class))) I would use that in a re.sub to collapse and replace all but

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Marko Rauhamaa
Jussi Piitulainen : > Michael Torrie writes: > >> On 06/15/2016 08:57 AM, Jussi Piitulainen wrote: >>> Marko Rauhamaa writes: And nothing in alister's answer suggests that. >>> >>> Now *I'm* surprised. >> >> He simply said, here's a regex that can parse the example string the OP >> gave us (

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Jussi Piitulainen
Michael Torrie writes: > On 06/15/2016 08:57 AM, Jussi Piitulainen wrote: >> Marko Rauhamaa writes: >>> And nothing in alister's answer suggests that. >> >> Now *I'm* surprised. > > He simply said, here's a regex that can parse the example string the OP > gave us (which maybe looked a bit like HT

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Michael Torrie
On 06/15/2016 08:57 AM, Jussi Piitulainen wrote: > Marko Rauhamaa writes: >> And nothing in alister's answer suggests that. > > Now *I'm* surprised. He simply said, here's a regex that can parse the example string the OP gave us (which maybe looked a bit like HTML, but like you say, may not be),

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Jussi Piitulainen
gt;>>> true_tail" >>>> >>>> I want to match the all the text surrounded by those " ", >>>> but only if those " " locate **in some distance** behind >>>> "true_head". That is, I expect to r

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread alister
atch the all the text surrounded by those " ", >>> but only if those " " locate **in some distance** behind >>> "true_head". That is, I expect to result to be like this: >>> >>> >>>import re result = re.findall("

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Jussi Piitulainen writes: > >> alister writes: >> >>> On Tue, 14 Jun 2016 20:28:24 -0700, Yubin Ruan wrote: Given a string like this: >>>string = "false_head aaa bbb false_tail \ true_head some_text_here ccc ddd eee t

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Marko Rauhamaa
Jussi Piitulainen : > alister writes: > >> On Tue, 14 Jun 2016 20:28:24 -0700, Yubin Ruan wrote: >>> Given a string like this: >>> >>> >>>string = "false_head aaa bbb false_tail \ >>> true_head some_text_here ccc ddd eee >>> true_tail" >>> >>> I want to match the all

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Jussi Piitulainen
behind >> "true_head". That is, I expect to result to be like this: >> >> >>>import re result = re.findall("the_regex",string) >> >>>print result >> ["ccc","ddd","eee"] >> >> How

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread alister
e this: > > >>>import re result = re.findall("the_regex",string) > >>>print result > ["ccc","ddd","eee"] > > How can I write a regex to match that? > I have try to use the **positive lookbehind assertion** in python

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Lawrence D’Oliveiro
On Wednesday, June 15, 2016 at 3:28:37 PM UTC+12, Yubin Ruan wrote: > I want to match the all the text surrounded by those " ", You are trying to use regex (type 3 grammar) to parse HTML (type 2 grammar) ? No can do

Re: python regex: variable length of positive lookbehind assertion

2016-06-15 Thread Vlastimil Brom
t;import re > >>>result = re.findall("the_regex",string) > >>>print result > ["ccc","ddd","eee"] > > How can I write a regex to match that? > I have try to use the **positive lookbehind assertion** in python regex, > b

Re: python regex: variable length of positive lookbehind assertion

2016-06-14 Thread Jussi Piitulainen
;>>result = re.findall("the_regex",string) > >>>print result > ["ccc","ddd","eee"] > > How can I write a regex to match that? > I have try to use the **positive lookbehind assertion** in python regex, > but it does not al

Re: python regex: variable length of positive lookbehind assertion

2016-06-14 Thread Yubin Ruan
On Wednesday, June 15, 2016 at 12:18:31 PM UTC+8, Lawrence D’Oliveiro wrote: > On Wednesday, June 15, 2016 at 3:28:37 PM UTC+12, Yubin Ruan wrote: > > > I want to match the all the text surrounded by those " ", > > You are trying to use regex (type 3 grammar) to parse HTML (type 2 grammar) >

python regex: variable length of positive lookbehind assertion

2016-06-14 Thread Yubin Ruan
;ccc","ddd","eee"] How can I write a regex to match that? I have try to use the **positive lookbehind assertion** in python regex, but it does not allowed variable length of lookbehind. Thanks in advance, Ruan -- https://mail.python.org/mailman/listinfo/python-list

python regex dna processing

2016-04-21 Thread Joel Goldstick
>From time to time there are DNA related question posted here. I came upon this in the hopes it may be useful to those who do that kind of software http://benchling.engineering/dna-regex-search/ -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- htt

Re: Python regex exercise

2015-04-04 Thread Vincent Davis
On Sat, Apr 4, 2015 at 5:51 PM, Thomas 'PointedEars' Lahn < pointede...@web.de> wrote: > > Do anyone have good links to python regex or other python problems for > > beginners but with solution. > > > > Please mail me. > ​I recently found​ this https

Re: Python regex exercise

2015-04-04 Thread Thomas 'PointedEars' Lahn
Robert Clove wrote: > Do anyone have good links to python regex or other python problems for > beginners but with solution. > > Please mail me. <http://www.catb.org/~esr/faqs/smart-questions.html#writewell> <http://www.catb.org/~esr/faqs/smart-questions.html#prune> &

Python regex exercise

2015-03-31 Thread Robert Clove
Hi All, Do anyone have good links to python regex or other python problems for beginners but with solution. Please mail me. Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: python regex "negative lookahead assertions" problems

2009-11-23 Thread Helmut Jarausch
On 11/22/09 16:05, Helmut Jarausch wrote: On 11/22/09 14:58, Jelle Smet wrote: Hi List, I'm trying to match lines in python using the re module. The end goal is to have a regex which enables me to skip lines which have ok and warning in it. But for some reason I can't get negative lookaheads wo

Re: python regex "negative lookahead assertions" problems

2009-11-22 Thread MRAB
Tim Chase wrote: import re line='2009-11-22 12:15:441 lmqkjsfmlqshvquhsudfhqf qlsfh qsduidfhqlsiufh qlsiuf qldsfhqlsifhqlius dfh warning qlsfj lqshf lqsuhf lqksjfhqisudfh qiusdfhq iusfh' re.match('.*(?!warning)',line) <_sre.SRE_Match object at 0xb75b1598> I would expect that this would NOT

Re: python regex "negative lookahead assertions" problems

2009-11-22 Thread Helmut Jarausch
On 11/22/09 14:58, Jelle Smet wrote: Hi List, I'm trying to match lines in python using the re module. The end goal is to have a regex which enables me to skip lines which have ok and warning in it. But for some reason I can't get negative lookaheads working, the way it's explained in "http://

Re: python regex "negative lookahead assertions" problems

2009-11-22 Thread Tim Chase
import re line='2009-11-22 12:15:441 lmqkjsfmlqshvquhsudfhqf qlsfh qsduidfhqlsiufh qlsiuf qldsfhqlsifhqlius dfh warning qlsfj lqshf lqsuhf lqksjfhqisudfh qiusdfhq iusfh' re.match('.*(?!warning)',line) <_sre.SRE_Match object at 0xb75b1598> I would expect that this would NOT match as it's a neg

python regex "negative lookahead assertions" problems

2009-11-22 Thread Jelle Smet
Hi List, I'm trying to match lines in python using the re module. The end goal is to have a regex which enables me to skip lines which have ok and warning in it. But for some reason I can't get negative lookaheads working, the way it's explained in "http://docs.python.org/library/re.html";. Con

Re: ignore special characters in python regex

2009-07-21 Thread Gabriel Genellina
En Tue, 21 Jul 2009 02:02:57 -0300, Astan Chee escribió: I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I

Re: ignore special characters in python regex

2009-07-21 Thread Astan Chee
I think the re.escape did the trick. to answer your questions: By "ignore" i meant instead of using non-alphanumeric characters that have special significance in regular expression (e.g. [|\]) and treat them as normal strings (i.e preceded by \), but since I don't know all the characters in reg

Re: ignore special characters in python regex

2009-07-20 Thread John Machin
On Jul 21, 3:02 pm, Astan Chee wrote: > Hi, > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? It would help if you were to

Re: ignore special characters in python regex

2009-07-20 Thread Frank Buss
Astan Chee wrote: > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? Maybe re.escape helps? -- Frank Buss, f...@frank-b

ignore special characters in python regex

2009-07-20 Thread Astan Chee
Hi, I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I have so far: fp = open('file.txt','r') notes = fp.readlines

Re: Perl-python regex-performance comparison

2009-03-03 Thread python
>> Python 2.7's regex will include possessive quantifiers, atomic groups, >> variable-length lookbehinds, and Unicode properties (at least the common >> ones), amongst other things. > Wow, that's excellent news! > Many thanks for all your efforts to enhance the re capabilities in > Python! +1 !!

Re: Perl / python regex / performance comparison

2009-03-03 Thread Terry Reedy
Ivan wrote: Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I looked around and found perl and python to be the nice. T

Re: Perl-python regex-performance comparison

2009-03-03 Thread Vlastimil Brom
2009/3/3 MRAB wrote: >> > Python 2.7's regex will include possessive quantifiers, atomic groups, > variable-length lookbehinds, and Unicode properties (at least the common > ones), amongst other things. > -- > http://mail.python.org/mailman/listinfo/python-list > Wow, that's excellent news! Many

Re: Perl-python regex-performance comparison

2009-03-03 Thread Steve Holden
Ivan wrote: > Hello everyone, > > I know this is not a direct python question, forgive me for that, but > maybe some of you will still be able to help me. I've been told that > for my application it would be best to learn a scripting language, so > I looked around and found perl and python to be t

Re: Perl-python regex-performance comparison

2009-03-03 Thread MRAB
Chris Rebert wrote: On Tue, Mar 3, 2009 at 9:05 AM, Ivan wrote: Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I loo

Re: Perl / python regex / performance comparison

2009-03-03 Thread Ciprian Dorin, Craciun
On Tue, Mar 3, 2009 at 7:03 PM, Ivan wrote: > Hello everyone, > > I know this is not a direct python question, forgive me for that, but > maybe some of you will still be able to help me. I've been told that > for my application it would be best to learn a scripting language, so > I looked around a

Re: Perl python - regex performance comparison

2009-03-03 Thread pruebauno
On Mar 3, 12:38 pm, Ivan wrote: > Hello everyone, > > I know this is not a direct python question, forgive me for that, but > maybe some of you will still be able to help me. I've been told that > for my application it would be best to learn a scripting language, so > I looked around and found per

Re: Perl-python regex-performance comparison

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 9:05 AM, Ivan wrote: > Hello everyone, > > I know this is not a direct python question, forgive me for that, but > maybe some of you will still be able to help me. I've been told that > for my application it would be best to learn a scripting language, so > I looked around a

Perl python - regex performance comparison

2009-03-03 Thread Ivan
Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I looked around and found perl and python to be the nice. Their syntax an

Re: Perl-python regex-performance comparison

2009-03-03 Thread Tino Wildenhain
Ivan wrote: Hello everyone, ... 1. Although it is all relatively similar, there are differences between regexes of these two. Which do you believe is the more powerful variant (maybe an example) ? 2. They are both interpreted languages, and I can't really be sure how they measure in speed. I

Perl-python regex-performance comparison

2009-03-03 Thread Ivan
Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I looked around and found perl and python to be the nice. Their syntax an

Perl-python regex-performance comparison

2009-03-03 Thread Ivan
Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I looked around and found perl and python to be the nice. Their syntax an

Perl / python regex / performance comparison

2009-03-03 Thread Ivan
Hello everyone, I know this is not a direct python question, forgive me for that, but maybe some of you will still be able to help me. I've been told that for my application it would be best to learn a scripting language, so I looked around and found perl and python to be the nice. Their syntax an

Re: Identifying unicode punctuation characters with Python regex

2008-11-19 Thread jhermann
> >>> P=P.replace('\\','').replace(']','\\]')   # escape both of them. re.escape() does this w/o any assumptions by your code about the regex implementation. -- http://mail.python.org/mailman/listinfo/python-list

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
On Nov 14, 12:30 pm, "Mark Tolonen" <[EMAIL PROTECTED]> wrote: > "Mark Tolonen" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > > > > "Shiao" <[EMAIL PROTECTED]> wrote in message > >news:[EMAIL PROTECTED] > >> Hello, > >> I'm trying to build a regex in python to identify pun

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
"Mark Tolonen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] "Shiao" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
"Shiao" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended syntax \p{P} that does just that. As far as I know, python re doesn't. Any ide

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
On Nov 14, 11:27 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I'm trying to build a regex in python to identify punctuation > > characters in all the languages. Some regex implementations support an > > extended syntax \p{P} that does just that. As far as I know, python re > > doesn't. Any

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Martin v. Löwis
> I'm trying to build a regex in python to identify punctuation > characters in all the languages. Some regex implementations support an > extended syntax \p{P} that does just that. As far as I know, python re > doesn't. Any idea of a possible alternative? You should use character classes. You can

Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended syntax \p{P} that does just that. As far as I know, python re doesn't. Any idea of a possible alternative? Apart from manually including the punctuat

Re: Python Regex Question

2008-10-29 Thread Terry Reedy
MalteseUnderdog wrote: Hi there I just started python (but this question isn't that trivial since I couldn't find it in google :) ) I have the following text file entries (simplified) start #frag 1 start x=Dog # frag 1 end stop start# frag 2 start x=Cat # frag 2 end stop start #fra

Re: Python Regex Question

2008-10-29 Thread Arnaud Delobelle
On Oct 29, 7:01 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I need a regex expression which returns the start to the x=ANIMAL for > > only the x=Dog fragments so all my entries should be start ... > > (something here) ... x=Dog .  So I am really interested in fragments 1 > > and 3 only. > > > My i

Re: Python Regex Question

2008-10-29 Thread Tim Chase
I need a regex expression which returns the start to the x=ANIMAL for only the x=Dog fragments so all my entries should be start ... (something here) ... x=Dog . So I am really interested in fragments 1 and 3 only. My idea (primitive) ^start.*?x=Dog doesn't work because clearly it would return r

Python Regex Question

2008-10-29 Thread MalteseUnderdog
Hi there I just started python (but this question isn't that trivial since I couldn't find it in google :) ) I have the following text file entries (simplified) start #frag 1 start x=Dog # frag 1 end stop start# frag 2 start x=Cat # frag 2 end stop start #frag 3 start x=Dog #frag 3

python regex character group matches...group...gotcha

2008-09-17 Thread christopher taylor
My apologies to the respondents - I failed to screen my test cases before kicking them out to the global python-list. but yes, the 'X' character in my test case was a mistake on my part. I'll give group() a shot. ct -- http://mail.python.org/mailman/listinfo/python-list

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
Steven D'Aprano wrote: Assuming that you want to find runs of \u escapes, simply use non-capturing parentheses: pat = re.compile(u"(?:\\\u[0-9A-F]{4})") Doesn't work for me: pat = re.compile(u"(?:\\\u[0-9A-F]{4})") it helps if you cut and paste the right line... here's a better v

Re: python regex character group matches

2008-09-17 Thread Steven D'Aprano
On Wed, 17 Sep 2008 09:27:47 -0400, christopher taylor wrote: > hello python-list! > > the other day, i was trying to match unicode character sequences that > looked like this: > > \\uAD0X... It is not clear what this is supposed to be. Is that matching a literal pair of backslashes, or a sing

Re: python regex character group matches

2008-09-17 Thread Steven D'Aprano
On Wed, 17 Sep 2008 15:56:31 +0200, Fredrik Lundh wrote: > Assuming that you want to find runs of \u escapes, simply use > non-capturing parentheses: > > pat = re.compile(u"(?:\\\u[0-9A-F]{4})") Doesn't work for me: >>> pat = re.compile(u"(?:\\\u[0-9A-F]{4})") UnicodeDecodeError: 'unico

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
christopher taylor wrote: my issue, is that the pattern i used was returning: [ '\\uAD0X', '\\u1BF3', ... ] when i expected: [ '\\uAD0X\\u1BF3', ] the code looks something like this: pat = re.compile("(\\\u[0-9A-F]{4})+", re.UNICODE|re.LOCALE) #print pat.findall(txt_line) results = pat.find

Re: python regex character group matches

2008-09-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Sep 2008 09:27:47 -0400, christopher taylor wrote: > the other day, i was trying to match unicode character sequences that > looked like this: > > \\uAD0X... > > my issue, is that the pattern i used was returning: > > [ '\\uAD0X', '\\u1BF3', ... ] > > when i expected: > > [ '\\uAD0X

python regex character group matches

2008-09-17 Thread christopher taylor
hello python-list! the other day, i was trying to match unicode character sequences that looked like this: \\uAD0X... my issue, is that the pattern i used was returning: [ '\\uAD0X', '\\u1BF3', ... ] when i expected: [ '\\uAD0X\\u1BF3', ] the code looks something like this: pat = re.compile

Re: Python regex question

2008-08-15 Thread Tim N. van der Leeuw
#x27;t fit in the parser-engine I had and I was close to making a release. But still: thanks! --Tim -- View this message in context: http://www.nabble.com/Python-regex-question-tp17773487p18997385.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python regex question

2008-06-11 Thread Gerhard Häring
Tim van der Leeuw wrote: Hi, I'm trying to create a regular expression for matching some particular XML strings. I want to extract the contents of a particular XML tag, only if it follows one tag, but not follows another tag. Complicating this, is that there can be any number of other tags in

Python regex question

2008-06-11 Thread Tim van der Leeuw
Hi, I'm trying to create a regular expression for matching some particular XML strings. I want to extract the contents of a particular XML tag, only if it follows one tag, but not follows another tag. Complicating this, is that there can be any number of other tags in between. So basically, my re

Re: Python regex

2008-03-13 Thread Adonis Vargas
Andrew Rekdal < wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such as... > > string = "/* CSS comment /*" > exp = "[^(/*)].*[^(*/)] " > > p = re.compile(exp) > q = p.search(string) > r = q.group() > > print r > >>>

Re: Python regex

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 8:22 pm, "Andrew Rekdal" <@comcast.net> wrote: [...] > in your expression above.. > > >>> r = re.compile(r'/\*(.*?)\*/') > > what does the 'r' do? It means the literal is a 'raw string' : >>> print 'Hi\nthere!' Hi there! >>> print r'Hi\nthere!' Hi\nthere! >>> If you haven't done so al

Re: Python regex

2008-03-13 Thread "Andrew Rekdal"
-- -- Andrew "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Mar 13, 8:03 pm, "Andrew Rekdal" <@comcast.net> wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such > as... > > string

Re: Python regex

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 8:03 pm, "Andrew Rekdal" <@comcast.net> wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such as... > > string = "/* CSS comment /*" > exp = "[^(/*)].*[^(*/)] " > > p = re.compile(exp) > q = p.search(string) > r

Re: Python regex

2008-03-13 Thread "Andrew Rekdal"
made error on last line... read as... > I would be saying if forward-slash AND asterisk appear in this order... > negate -- -- Andrew "Andrew Rekdal @comcast.net>" < wrote in message news:[EMAIL PROTECTED] >I hope posting is ok here for this question... > > I am attempting to extract the tex

Python regex

2008-03-13 Thread "Andrew Rekdal"
I hope posting is ok here for this question... I am attempting to extract the text from a CSS comment using 're' such as... string = "/* CSS comment /*" exp = "[^(/*)].*[^(*/)] " p = re.compile(exp) q = p.search(string) r = q.group() print r >>CSS comment although this works to a degree... I

Re: python regex: misbehaviour with "\r" (0x0D) as Newline character in Unicode Mode

2008-01-27 Thread Fredrik Lundh
Arian Sanusi wrote: > concerning to unicode, "\n", "\r "and "\r\n" (0x000A, 0x000D and 0x000D+0x000A) should be threatened as newline character the link says that your application should treat them line terminators, not that they should all be equal to a new line character. to split on Unicode

python regex: misbehaviour with "\r" (0x0D) as Newline character in Unicode Mode

2008-01-27 Thread Arian Sanusi
Hi, concerning to unicode, "\n", "\r "and "\r\n" (0x000A, 0x000D and 0x000D+0x000A) should be threatened as newline character at least this is how i understand it: (http://en.wikipedia.org/wiki/Newline#Unicode) obviously, the re module does not care, and on unix, only threatens \n as newline c

Re: python/regex question... hope someone can help

2007-12-09 Thread Gabriel Genellina
En Sun, 09 Dec 2007 16:45:53 -0300, charonzen <[EMAIL PROTECTED]> escribió: >> [John Machin] Another suggestion is to ensure that the job >> specification is not >> overly simplified. How did you parse the text into "words" in the >> prior exercise that produced the list of bigrams? Won't you

Re: python/regex question... hope someone can help

2007-12-09 Thread charonzen
> Another suggestion is to ensure that the job specification is not > overly simplified. How did you parse the text into "words" in the > prior exercise that produced the list of bigrams? Won't you need to > use the same parsing method in the current exercise of tagging the > bigrams with an under

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: The following *may* come close to doing what your revised spec requires: import re def ch_replace2(alist, text): for bigram in alist: pattern = r'\b' + bigram.replace('_', ' ') + r'\b' text = re.sub(pattern, bigram, text)

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: > I have a list of strings. These strings are previously selected > bigrams with underscores between them ('and_the', 'nothing_given', and > so on). I need to write a regex that will read another text string > that this list was derived from

python/regex question... hope someone can help

2007-12-08 Thread charonzen
I have a list of strings. These strings are previously selected bigrams with underscores between them ('and_the', 'nothing_given', and so on). I need to write a regex that will read another text string that this list was derived from and replace selections in this text string with those from my l

Re: Python Regex Question

2007-09-21 Thread David
> re.search(expr, string) compiles and searches every time. This can > potentially be more expensive in calculating power. especially if you > have to use the expression a lot of times. The re module-level helper functions cache expressions and their compiled form in a dict. They are only compiled

Re: Python Regex Question

2007-09-21 Thread Ivo
crybaby wrote: > On Sep 20, 4:12 pm, Tobiah <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> I need to extract the number on each >> i.e 49.950 from the following: >>>  49.950  >>> The actual number between:  49.950  can be any number of >>> digits before decimal and after decimal. >>>  #

Re: Python Regex Question

2007-09-20 Thread crybaby
On Sep 20, 4:12 pm, Tobiah <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I need to extract the number on each > > i.e 49.950 from the following: > > >  49.950  > > > The actual number between:  49.950  can be any number of > > digits before decimal and after decimal. > > >  ##.

Re: Python Regex Question

2007-09-20 Thread Gerardo Herzig
[EMAIL PROTECTED] wrote: >I need to extract the number on each >i.e 49.950 from the following: > > 49.950  > >The actual number between:  49.950  can be any number of >digits before decimal and after decimal. > > ##.  > >How can I just extract the real/integer number using regex? > > >

Re: Python Regex Question

2007-09-20 Thread Tobiah
[EMAIL PROTECTED] wrote: > I need to extract the number on each > i.e 49.950 from the following: > >  49.950  > > The actual number between:  49.950  can be any number of > digits before decimal and after decimal. > >  ##.  > > How can I just extract the real/integer number using rege

Python Regex Question

2007-09-20 Thread joemystery123
I need to extract the number on each  49.950  The actual number between:  49.950  can be any number of digits before decimal and after decimal.  ##.  How can I just extract the real/integer number using regex? -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python REGEX Question

2007-05-12 Thread James T. Dennis
johnny <[EMAIL PROTECTED]> wrote: > I need to get the content inside the bracket. > eg. some characters before bracket (3.12345). > I need to get whatever inside the (), in this case 3.12345. > How do you do this with python regular expression? I'm going to presume that you mean something like:

Re: Simple Python REGEX Question

2007-05-11 Thread Steven D'Aprano
On Fri, 11 May 2007 08:54:31 -0700, johnny wrote: > I need to get the content inside the bracket. > > eg. some characters before bracket (3.12345). > > I need to get whatever inside the (), in this case 3.12345. > > How do you do this with python regular expression? Why would you bother? If yo

Re: Simple Python REGEX Question

2007-05-11 Thread John Machin
On May 12, 2:21 am, Gary Herron <[EMAIL PROTECTED]> wrote: > johnny wrote: > > I need to get the content inside the bracket. > > > eg. some characters before bracket (3.12345). > > > I need to get whatever inside the (), in this case 3.12345. > > > How do you do this with python regular expression?

Re: Simple Python REGEX Question

2007-05-11 Thread Gary Herron
johnny wrote: > I need to get the content inside the bracket. > > eg. some characters before bracket (3.12345). > > I need to get whatever inside the (), in this case 3.12345. > > How do you do this with python regular expression? > >>> import re >>> x = re.search("[0-9.]+", "(3.12345)") >>> pr

Simple Python REGEX Question

2007-05-11 Thread johnny
I need to get the content inside the bracket. eg. some characters before bracket (3.12345). I need to get whatever inside the (), in this case 3.12345. How do you do this with python regular expression? -- http://mail.python.org/mailman/listinfo/python-list

Re: String Pattern Matching: regex and Python regex documentation

2006-09-26 Thread Ilias Lazaridis
Steve Holden wrote: > Xah Lee wrote: ... > > This project was undertaken as a response to a challenge put forth to > > me with a $100 reward, on 2005-04-12 on comp.lang.python newsgroup. I > > never received the due reward. > > > Your reading skills must be terrible. You never received the reward >

Re: String Pattern Matching: regex and Python regex documentation

2006-09-24 Thread Steve Holden
Xah Lee wrote: > Xah Lee wrote: > « the Python regex documentation is available at: > http://xahlee.org/perl-python/python_re-write/lib/module-re.html ...» > > Jürgen Exner wrote: > «Yeah, sure, and the Perl regex documentation is available at 'perldoc > perlre'.

Re: String Pattern Matching: regex and Python regex documentation

2006-09-24 Thread Xah Lee
Xah Lee wrote: « the Python regex documentation is available at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html ...» Jürgen Exner wrote: «Yeah, sure, and the Perl regex documentation is available at 'perldoc perlre'. So what? Is that anything new or surprising?»

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread J�rgen Exner
Ilias Lazaridis wrote: > Xah Lee wrote: >> the Python regex documentation is available at: >> http://xahlee.org/perl-python/python_re-write/lib/module-re.html Yeah, sure, and the Perl regex documentation is available at 'perldoc perlre'. So what? Is that anythin

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread John Machin
Paul McGuire wrote: > "Steve Holden" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > > Ilias Lazardis meets Xah Lee. I just *know* we're in for trouble now ... > > > > regards > > Steve > > A sign of the End Times, perhaps? > Indeed. Armageddon outa here ;-) -- http://

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread Paul McGuire
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Ilias Lazardis meets Xah Lee. I just *know* we're in for trouble now ... > > regards > Steve A sign of the End Times, perhaps? -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread Steve Holden
Ilias Lazaridis wrote: > [followup to c.l.py] > > Xah Lee wrote: > >>the Python regex documentation is available at: >>http://xahlee.org/perl-python/python_re-write/lib/module-re.html >> >>Note that, i've just made the terms of use clear. >> >>

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread Ilias Lazaridis
[followup to c.l.py] Xah Lee wrote: > the Python regex documentation is available at: > http://xahlee.org/perl-python/python_re-write/lib/module-re.html > > Note that, i've just made the terms of use clear. > > Also, can anyone answer what is the precise terms of li

String Pattern Matching: regex and Python regex documentation

2006-09-17 Thread Xah Lee
the Python regex documentation is available at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html Note that, i've just made the terms of use clear. Also, can anyone answer what is the precise terms of license of the official python documentation? The official python.org doc

  1   2   >