On Monday, October 10, 2016 at 3:58:56 PM UTC+1, infos...@gmail.com wrote:
> Hey guys!
>
> I am new to learning regex in python and I'm wondering how do I use regex in
> python to store the integers(positive and negative) i want into a list!
>
> For e.g.
>
> This is the data in a list.
>
Hey guys!
I am new to learning regex in python and I'm wondering how do I use regex in
python to store the integers(positive and negative) i want into a list!
For e.g.
This is the data in a list.
[u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)',
Hey guys!
I am new to learning regex in python and I'm wondering how do I use regex in
python to store the integers(positive and negative) i want into a list!
For e.g.
This is the data in a list.
[u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)',
James Smith wrote:
I want the last 1
I can't this to work:
pattern=re.compile( (\d+)$ )
match=pattern.match( LINE: 235 : Primary Shelf Number (attempt 1): 1)
print match.group()
pattern = re.compile((\d+)$)
match = pattern.search( LINE: 235 : Primary Shelf Number (attempt 1):
1)
Peter Otten __pete...@web.de writes:
pattern = re.compile((\d+)$)
match = pattern.search( LINE: 235 : Primary Shelf Number (attempt 1): 1)
match.group()
'1'
An alternative way to accomplish the above using the ‘match’ method::
import re
pattern = re.compile(^.*:(? *)(\d+)$)
I want the last 1
I can't this to work:
pattern=re.compile( (\d+)$ )
match=pattern.match( LINE: 235 : Primary Shelf Number (attempt 1): 1)
print match.group()
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk
yuri.slobodyan...@gmail.com wrote:
Good day everyone,
I am trying to make this pretty simple regex to work but got stuck,
I'd appreciate your help .
Some people, when confronted with a problem, think 'I know, I'll use
regular expressions.'
Thanks everybody , and especially Chris - i used split and it took me 15
mins to make it work :)
The final version looks like:
from datetime import datetime, date, time
today_day = datetime.now()
time_tuple= today_day.timetuple()
hhh = open(file_with_data.data,'r')
for nnn in hhh:
if
On Tue, 12 Apr 2011 15:06:25 +0300
Yuri Slobodyanyuk yuri.slobodyan...@gmail.com wrote:
Thanks everybody , and especially Chris - i used split and it took me 15
mins to make it work :)
That's great. One thing though...
for nnn in hhh:
if nnn.split()[2] == str(time_tuple[1]).strip('
Thanks for the insight, while this code will run once a week and
optimization isn't really a must here, it is
still a good idea not to leave half-baked code behind me, especially given
that it will be running on this server for the next 13 years ;)
I have one doubt though . Doesn't using the
On Tue, 12 Apr 2011 22:11:55 +0300
Yuri Slobodyanyuk yuri.slobodyan...@gmail.com wrote:
Thanks for the insight, while this code will run once a week and
optimization isn't really a must here, it is
still a good idea not to leave half-baked code behind me, especially given
that it will be
Good day everyone,
I am trying to make this pretty simple regex to work but got stuck,
I'd appreciate your help .
Task: Get current date , then read file of format below, find the line that
matches
the current date of month,month and year and extract the number from such
line.
Here is what I did ,
On Tue, Apr 12, 2011 at 10:50 AM, Yuri Slobodyanyuk
yuri.slobodyan...@gmail.com wrote:
Good day everyone,
I am trying to make this pretty simple regex to work but got stuck,
I'd appreciate your help .
Task: Get current date , then read file of format below, find the line that
matches
the
On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk
yuri.slobodyan...@gmail.com wrote:
Good day everyone,
I am trying to make this pretty simple regex to work but got stuck,
I'd appreciate your help .
Task: Get current date , then read file of format below, find the line that
matches
the
Hi,
i have a line that looks something like:
2.234e+04 3.456e+02 7.234e+07 1.543e+04: some description
I would like to extract all the numbers. From the python website i got the
following expression for matching what in c is %e (i.e. scientific
format):
(see
On 03/03/2011 17:33, maf...@nmsu.edu wrote:
Hi,
i have a line that looks something like:
2.234e+04 3.456e+02 7.234e+07 1.543e+04: some description
I would like to extract all the numbers. From the python website i got the
following expression for matching what in c is %e (i.e. scientific
Thanks,
works great.
matt
On 3/3/2011 10:53 AM, MRAB wrote:
On 03/03/2011 17:33, maf...@nmsu.edu wrote:
Hi,
i have a line that looks something like:
2.234e+04 3.456e+02 7.234e+07 1.543e+04: some description
I would like to extract all the numbers. From the python website i
got the
Schif Schaf wrote:
On Feb 7, 8:57 am, Tim Chase python.l...@tim.thechases.com wrote:
Steve Holden wrote:
Really? Under what circumstances does a simple one-for-one character
replacement operation fail?
Failure is only defined in the clarified context of what the OP
wants :)
Here is one simple solution :
intext = Lorem [ipsum] dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut [labore] et [dolore] magna aliqua.
intext.replace('[', '{').replace(']',
'}')
'Lorem {ipsum} dolor sit amet, consectetur adipisicing elit, sed do eiusmod
On 07 Feb 2010, at 10:03, Shashwat Anand wrote:
Here is one simple solution :
intext = Lorem [ipsum] dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut [labore] et
[dolore] magna aliqua.
intext.replace('[', '{').replace(']', '}')
'Lorem {ipsum} dolor sit
Schif Schaf wrote:
On Feb 7, 12:19 am, Alf P. Steinbach al...@start.no wrote:
I haven't used regexps in Python before, but what I did was (1) look in the
documentation,
[snip]
code
import re
text = (
Lorem [ipsum] dolor sit amet, consectetur,
adipisicing elit, sed do eiusmod
@ Rocteur CC wrote:
On 07 Feb 2010, at 10:03, Shashwat Anand wrote:
Here is one simple solution :
intext = Lorem [ipsum] dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut [labore] et [dolore] magna
aliqua.
intext.replace('[', '{').replace(']',
'}')
Schif Schaf schifsc...@gmail.com writes:
(brackets replaced by braces). I can do that with Perl pretty easily:
for () {
s/\[(.+?)\]/\{$1\}/g;
print;
}
Just curious, but since this is just transpose, then why not simply
tr/[]/{}/? I.e. why use a regular expression at all
Tim Chase wrote:
Schif Schaf wrote:
On Feb 7, 12:19 am, Alf P. Steinbach al...@start.no wrote:
I haven't used regexps in Python before, but what I did was (1) look
in the
documentation,
[snip]
code
import re
text = (
Lorem [ipsum] dolor sit amet, consectetur,
adipisicing
Steve Holden wrote:
Tim Chase wrote:
And to answer those who are reaching for other non-regex (whether string
translations or .replace(), or pyparsing) solutions, it depends on what
you want to happen in pathological cases like
s = Dangling closing]
with properly [[nested]] and
On Feb 7, 8:57 am, Tim Chase python.l...@tim.thechases.com wrote:
Steve Holden wrote:
Really? Under what circumstances does a simple one-for-one character
replacement operation fail?
Failure is only defined in the clarified context of what the OP
wants :) Replacement operations only fail
Hi,
I've got some text that looks like this:
Lorem [ipsum] dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut [labore] et [dolore] magna aliqua.
and I want to make it look like this:
Lorem {ipsum} dolor sit amet, consectetur
adipisicing
* Schif Schaf:
Hi,
I've got some text that looks like this:
Lorem [ipsum] dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut [labore] et [dolore] magna aliqua.
and I want to make it look like this:
Lorem {ipsum} dolor sit amet, consectetur
On Feb 7, 12:19 am, Alf P. Steinbach al...@start.no wrote:
I haven't used regexps in Python before, but what I did was (1) look in the
documentation,
Hm. I checked in the repl, running `import re; help(re)` and the docs
on the `sub()` method didn't say anything about using back-refs in the
I'm having trouble creating a regex pattern that matches a string that
has an optional substring in it. What I'm looking for is a pattern
that matches both of these strings:
Subject: [PATCH 08/18] This is the patch name
Subject: This is the patch name
What I want is to extract the This is the
On Oct 14, 9:51 am, Timur Tabi timur.t...@gmail.com wrote:
I'm having trouble creating a regex pattern that matches a string that
has an optional substring in it. What I'm looking for is a pattern
that matches both of these strings:
Subject: [PATCH 08/18] This is the patch name
Subject:
:
2009/10/14 Timur Tabi timur.t...@gmail.com:
I'm having trouble creating a regex pattern that matches a string that
has an optional substring in it. What I'm looking for is a pattern
that matches both of these strings:
Subject: [PATCH 08/18] This is the patch name
Subject: This is the
:
2009/10/14 Timur Tabi timur.t...@gmail.com:
Never mind ... I figured it out. The middle block should have been [\w
\s/]*
This is fragile - you'll have to keep adding extra characters to match
if the input turns out to contain them.
-[]z.
--
On Wed, Oct 14, 2009 at 10:30 AM, Zero Piraeus sche...@gmail.com wrote:
'(?:etc)' instead of '(etc)' are non-grouping parentheses (since you
apparently don't care about that bit).
Ah yes, thanks.
'[^\]]' instead of '[\w\s]' matches everything except a closing bracket.
I originally had just
On Thu, 06 Aug 2009 17:02:44 +0100, MRAB wrote:
The character class \d is equivalent to [0-9]
Not for Unicode, which is the default in 3.x.
--
http://mail.python.org/mailman/listinfo/python-list
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be any length 1 or
greater. Example:
FILEVERSION 1,45,10082,3
The
Robert Dailey wrote:
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be any length 1 or
greater. Example:
On Aug 7, 1:35 am, Robert Dailey rcdai...@gmail.com wrote:
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION 1,45,10082,3
Would it be easier to do it without regex? The
On Aug 6, 11:02 am, MRAB pyt...@mrabarnett.plus.com wrote:
Robert Dailey wrote:
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol
Robert Dailey wrote:
On Aug 6, 11:02 am, MRAB pyt...@mrabarnett.plus.com wrote:
Robert Dailey wrote:
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The #
On 06/08/09 08:35, Robert Dailey wrote:
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be any length 1 or
On Aug 6, 11:12 am, Roman atra...@gmail.com wrote:
On 06/08/09 08:35, Robert Dailey wrote:
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The
On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote:
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be any length
Nobody wrote:
On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote:
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be
On Aug 7, 7:23 am, Ethan Furman et...@stoneleaf.us wrote:
Nobody wrote:
On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote:
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
On Thu, 06 Aug 2009 14:23:47 -0700, Ethan Furman wrote:
[0-9]+ allows any number of leading zeros, which is sometimes undesirable.
Using:
(0|[1-9][0-9]*)
is more robust.
You make a good point about possibly being undesirable, but I question
the assertion that your solution is
In article mailman.3998.1248989346.8015.python-l...@python.org,
MRAB pyt...@mrabarnett.plus.com wrote:
Nobody wrote:
On Thu, 30 Jul 2009 10:29:09 -0700, rurpy wrote:
regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)')
You might also want to consider that some country
codes such as co for
I'm trying to figure out how to write efficiently write a regex for
domain names with a particular top level domain. Let's say, I want to
grab all domain names with country codes .us, .au, and .de.
I could create three different regexs that would work:
regex = re.compile(r'[\w\-\.]+\.us)
regex =
Feyo wrote:
I'm trying to figure out how to write efficiently write a regex for
domain names with a particular top level domain. Let's say, I want to
grab all domain names with country codes .us, .au, and .de.
I could create three different regexs that would work:
regex =
Feyo wrote:
I'm trying to figure out how to write efficiently write a regex for
domain names with a particular top level domain. Let's say, I want to
grab all domain names with country codes .us, .au, and .de.
I could create three different regexs that would work:
regex =
On Jul 30, 11:56 am, MRAB pyt...@mrabarnett.plus.com wrote:
Feyo wrote:
I'm trying to figure out how to write efficiently write a regex for
domain names with a particular top level domain. Let's say, I want to
grab all domain names with country codes .us, .au, and .de.
I could create
On Jul 30, 9:56 am, MRAB pyt...@mrabarnett.plus.com wrote:
Feyo wrote:
I'm trying to figure out how to write efficiently write a regex for
domain names with a particular top level domain. Let's say, I want to
grab all domain names with country codes .us, .au, and .de.
I could create
Nobody wrote:
On Thu, 30 Jul 2009 10:29:09 -0700, rurpy wrote:
regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)')
You might also want to consider that some country
codes such as co for Columbia might match more than
you want, for example:
re.match(r'[\w\-\.]+\.(?:us|au|de|co)', 'foo.boo.com')
I have a file with lines in the following format.
pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
I would like to pull out some of the values and
This isn't a regex solution, but uses pyparsing instead. Pyparsing
helps you construct recursive-descent parsers, and maintains a code
structure that is easy to compose, read, understand, maintain, and
remember what you did 6-months after you wrote it in the first place.
Download pyparsing at
Scott wrote:
I have a file with lines in the following format.
pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
I would like to pull out some
Paul McGuire wrote:
This isn't a regex solution, but uses pyparsing instead. Pyparsing
helps you construct recursive-descent parsers, and maintains a code
structure that is easy to compose, read, understand, maintain, and
remember what you did 6-months after you wrote it in the first place.
Catalina Scott A Contr AFCA/EVEO schrieb:
I have a file with lines in the following format.
pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
I
Christopher Subich schrieb:
Paul McGuire wrote:
[...]
For the example listed, pyparsing is even overkill; the OP should
probably use the csv module.
But the OP wants to parse lines with key=value pairs, not simply lines
with comma separated values. Using the csv module will just separate
Fredrik Lundh wrote:
Scott wrote:
I have a file with lines in the following format.
pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
I
Dennis Benzinger wrote:
Christopher Subich schrieb:
Paul McGuire wrote:
[...]
For the example listed, pyparsing is even overkill; the OP should
probably use the csv module.
But the OP wants to parse lines with key=value pairs, not simply lines
with comma separated values. Using the csv
Catalina Scott A Contr AFCA/EVEO wrote:
I have a file with lines in the following format.
pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
I
62 matches
Mail list logo