When I'm debugging a regex I make the regex shorter and shorter to figure out
what the problem is.
Try starting with re.compile(r'm') and then add the chars one by one seeing
what happens as the string gets longer.
Barry
> On 19 Sep 2019, at 09:41, Pradeep Patra wrote:
>
> I am using python 2
On Fri, Sep 20, 2019 at 1:07 AM Pradeep Patra wrote:
>
> Thanks David /Anthony for your help. I figured out the issue myself. I
> dont need any ^, $ etc to the regex pattern and the plain string (for exp
> my-dog) works fine. I am looking at creating a generic method so that
> instead of passing
Thanks David /Anthony for your help. I figured out the issue myself. I
dont need any ^, $ etc to the regex pattern and the plain string (for exp
my-dog) works fine. I am looking at creating a generic method so that
instead of passing my-dog i can pass my-cat or blah blah. I am thinking of
creating
On Thu, 19 Sep 2019 at 19:34, Pradeep Patra wrote:
> Thanks David for your quick help. Appreciate it. When I tried on python 2.7.3
> the same thing you did below I got the error after matches.group(0) as
> follows:
>
> AttributeError: NoneType object has no attribute 'group'.
>
> I tried to che
Thanks David for your quick help. Appreciate it. When I tried on python
2.7.3 the same thing you did below I got the error after matches.group(0)
as follows:
AttributeError: NoneType object has no attribute 'group'.
I tried to check 'None' for no match for re.search as the documentation
says but
On Thu, 19 Sep 2019 at 18:41, Pradeep Patra wrote:
> On Thursday, September 19, 2019, Pradeep Patra
> wrote:
>> On Thursday, September 19, 2019, David wrote:
>>> On Thu, 19 Sep 2019 at 17:51, Pradeep Patra
>>> wrote:
>>> > pattern=re.compile(r'^my\-dog$')
>>> > matches = re.search(mystr)
>>
I am using python 2.7.6 but I also tried on python 3.7.3.
On Thursday, September 19, 2019, Pradeep Patra
wrote:
> Beginning of the string. But I tried removing that as well and it still
> could not find it. When I tested at www.regex101.com and it matched
> successfully whereas I may be wrong. C
On Thu, 19 Sep 2019 at 17:51, Pradeep Patra wrote:
>
> pattern=re.compile(r'^my\-dog$')
> matches = re.search(mystr)
>
> In the above example both cases(match/not match) the matches returns "None"
Hi, do you know what the '^' character does in your pattern?
--
https://mail.python.org/mailman/lis
On Friday, April 14, 2017 at 4:12:27 PM UTC+1, Malik Rumi wrote:
> I am running some tests using the site regex101 to figure out the correct
> regexs to use for a project. I was surprised at how slow it was, constantly
> needing to increase the timeouts. I went Googling for a reason, and solution
On 04/14/2017 08:12 AM, Malik Rumi wrote:
I am running some tests using the site regex101 to figure out the correct
regexs to use for a project. I was surprised at how slow it was, constantly
needing to increase the timeouts. I went Googling for a reason, and solution,
and found Russ Cox’s art
Malik Rumi wrote:
> I am running some tests using the site regex101 to figure out the correct
> regexs to use for a project. I was surprised at how slow it was,
> constantly needing to increase the timeouts. I went Googling for a reason,
> and solution, and found Russ Cox’s article from 2007:
> ht
-Original Message-
From: Python-list [mailto:python-list-
bounces+jcasale=activenetwerx@python.org] On Behalf Of Malik Rumi
Sent: Friday, April 14, 2017 9:12 AM
To: python-list@python.org
Subject: Regular Expressions, Speed, Python, and NFA
> I am running some tests using the site rege
On Sat, 15 Apr 2017 01:12 am, Malik Rumi wrote:
> I couldn’t understand why, if this was even remotely correct,
> we don’t use NFA in Python
[...]
> I don’t think I’m qualified to take on the idea of creating
> a new NFA module for Python.
If not you, then who should do it?
Python is open so
On Thursday, November 5, 2015 at 8:12:22 AM UTC-7, Seymore4Head wrote:
> On Thu, 05 Nov 2015 11:54:20 +1100, Steven D'Aprano
> wrote:
> >On Thu, 5 Nov 2015 10:02 am, Seymore4Head wrote:
> >> So far the only use I have for regex is to replace slicing, but I
> >> think it is an improvement.
> >
> >
On Fri, Nov 6, 2015 at 3:36 PM, Christian Gollwitzer wrote:
> Am 06.11.15 um 20:52 schrieb ru...@yahoo.com:
>>
>> I have always thought lexing
>> and parsing solutions for Python were a weak spot in the Python eco-
>> system and I was about to write that I would love to see a PEG parser
>> for pyt
Am 06.11.15 um 20:52 schrieb ru...@yahoo.com:
I have always thought lexing
and parsing solutions for Python were a weak spot in the Python eco-
system and I was about to write that I would love to see a PEG parser
for python when I saw this:
http://fdik.org/pyPEG/
Unfortunately it suffers from
On 11/05/2015 01:18 AM, Christian Gollwitzer wrote:
> Am 05.11.15 um 06:59 schrieb rurpy:
>>> Can you call yourself a well-rounded programmer without at least
>>> a basic understanding of some regex library? Well, probably not.
>>> But that's part of the problem with regexes. They have, to some
>>>
On Thu, 05 Nov 2015 11:54:20 +1100, Steven D'Aprano
wrote:
>On Thu, 5 Nov 2015 10:02 am, Seymore4Head wrote:
>
>> So far the only use I have for regex is to replace slicing, but I
>> think it is an improvement.
>
>I don't understand this. This is like saying "so far the only use I have for
>a san
On 2015-11-05 23:05, Steven D'Aprano wrote:
> Oh the shame, I knew that. Somehow I tangled myself in a knot,
> thinking that it had to be 1 *followed by* zero or more characters.
> But of course it's not a glob, it's a regex.
But that's a good reminder of fnmatch/glob modules too. Sometimes
all y
Steven D'Aprano writes:
>On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote:
>> I tried Tim's example
>>
>> $ seq 5 | grep '1*'
>> 1
>> 2
>> 3
>> 4
>> 5
>> $
>I don't understand this. What on earth is grep matching? How does "4"
>match "1*"?
>> which surprised me because I remembered that there u
On Thu, 5 Nov 2015 07:33 pm, Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote:
>>
>>> I tried Tim's example
>>>
>>> $ seq 5 | grep '1*'
>>> 1
>>> 2
>>> 3
>>> 4
>>> 5
>>> $
>>
>> I don't understand this. What on earth is grep matching? How does "4"
Op 05-11-15 om 01:33 schreef Chris Angelico:
> "I want to swim from Sydney to Los Angeles, but my gloves keep wearing
> out half way across the Pacific. How can I make my gloves strong
> enough to get me to LA?"
>
> Response 1: "If you use industrial-strength gloves and go via Papua
> New Guinea, y
Steven D'Aprano wrote:
> On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote:
>
>> I tried Tim's example
>>
>> $ seq 5 | grep '1*'
>> 1
>> 2
>> 3
>> 4
>> 5
>> $
>
> I don't understand this. What on earth is grep matching? How does "4"
> match "1*"?
Look for zero or more "1". Written in Python:
for
Am 05.11.15 um 06:59 schrieb ru...@yahoo.com:
Can you call yourself a well-rounded programmer without at least a basic
understanding of some regex library? Well, probably not. But that's part of
the problem with regexes. They have, to some degree, driven out potentially
better -- or at least diff
On Thu, Nov 5, 2015 at 6:55 PM, Gregory Ewing
wrote:
> Tim Chase wrote:
>
>> You get even crazier when you start adding zgrep/zegrep/zfgrep.
>
>
> It's fitting somehow that we should need an RE
> to describe all the possible names of the grep
> command.
Regex engine golf: Find the shortest regex
Tim Chase wrote:
You get even crazier when you start adding zgrep/zegrep/zfgrep.
It's fitting somehow that we should need an RE
to describe all the possible names of the grep
command.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On Wednesday, November 4, 2015 at 7:46:24 PM UTC-7, Chris Angelico wrote:
> On Thu, Nov 5, 2015 at 11:24 AM, rurpy wrote:
> The "take away" that I recommend is: Rurpy loves to argue in favour of
> regular expressions,
No, I don't love it, I quite dislike it.
> but as you can see from the other p
On 11/04/2015 07:24 PM, Steven D'Aprano wrote:
> On Thu, 5 Nov 2015 11:24 am, wrote:
>
>> You will find they are an indispensable tool, not just in Python
>> programming but in many aspects of computer use.
>
> You will find them a useful tool, but not indispensable by any means.
>
> Hint:
>
> - Ho
On Wednesday, November 4, 2015 at 7:31:34 PM UTC-7, Steven D'Aprano wrote:
> On Thu, 5 Nov 2015 11:13 am, rurpy wrote:
>
> > There would be far fewer computer languages, and they would be much
> > more primitive if regular expressions (and the fundamental concepts
> > that they express) did not ex
On 11/04/2015 05:33 PM, Chris Angelico wrote:
> On Thu, Nov 5, 2015 at 11:13 AM, rurpy--- via Python-list
> wrote:
>> On 11/04/2015 07:52 AM, Chris Angelico wrote:
>>> On Thu, Nov 5, 2015 at 1:38 AM, rurpy wrote:
I'm afraid you are making a category error but perhaps that's in
part becau
Steven D'Aprano writes:
> Yes yes, I know that regexes aren't the only tool in my tool box, but
> *right now* I want to learn how to use regexes.
I'll gently suggest this isn't a particularly good forum to do so.
Learn them with a tool like http://www.regexr.com/> and a tutorial
http://www.usna
Steven D'Aprano writes:
> On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote:
>
> > I tried Tim's example
> >
> > $ seq 5 | grep '1*'
> > 1
> > 2
> > 3
> > 4
> > 5
> > $
>
> I don't understand this. What on earth is grep matching? How does "4"
> match "1*"?
You can experiment with regular expressio
On 2015-11-05 13:28, Steven D'Aprano wrote:
> > I tried Tim's example
> >
> > $ seq 5 | grep '1*'
> > 1
> > 2
> > 3
> > 4
> > 5
> > $
>
> I don't understand this. What on earth is grep matching? How does
> "4" match "1*"?
The line with "4" matches "zero or more 1s". If it was searching for
a
On Thu, Nov 5, 2015 at 11:24 AM, rurpy--- via Python-list
wrote:
> On Wednesday, November 4, 2015 at 4:05:06 PM UTC-7, Seymore4Head wrote:
>>[...]
>> I am still here, but I have to admit I am not picking up too much.
>
> The "take away" I recommend is: the folks here are often way
> overly negativ
On Thu, 5 Nov 2015 11:13 am, ru...@yahoo.com wrote:
> There would be far fewer computer languages, and they would be much
> more primitive if regular expressions (and the fundamental concepts
> that they express) did not exist.
Well, that's certainly true. But only because contra-factual statemen
On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote:
> I tried Tim's example
>
> $ seq 5 | grep '1*'
> 1
> 2
> 3
> 4
> 5
> $
I don't understand this. What on earth is grep matching? How does "4"
match "1*"?
> which surprised me because I remembered that there usually weren't any
> matching lines wh
On Thu, 5 Nov 2015 11:24 am, ru...@yahoo.com wrote:
> You will find they are an indispensable tool, not just in Python
> programming but in many aspects of computer use.
You will find them a useful tool, but not indispensable by any means.
Hint:
- How many languages make arithmetic a built-in p
On Thu, 5 Nov 2015 10:02 am, Seymore4Head wrote:
> So far the only use I have for regex is to replace slicing, but I
> think it is an improvement.
I don't understand this. This is like saying "so far the only use I have for
a sandwich press is to replace my coffee pot". Regular expressions and
sl
On Thu, Nov 5, 2015 at 11:13 AM, rurpy--- via Python-list
wrote:
> On 11/04/2015 07:52 AM, Chris Angelico wrote:
>> On Thu, Nov 5, 2015 at 1:38 AM, rurpy wrote:
>>> I'm afraid you are making a category error but perhaps that's in
>>> part because I wasn't clear. I was not talking about computer
>
On Wednesday, November 4, 2015 at 4:05:06 PM UTC-7, Seymore4Head wrote:
>[...]
> I am still here, but I have to admit I am not picking up too much.
The "take away" I recommend is: the folks here are often way
overly negative regarding regular expressions and that you not
ignore them, but take the
On 11/04/2015 07:52 AM, Chris Angelico wrote:
> On Thu, Nov 5, 2015 at 1:38 AM, rurpy wrote:
>> I'm afraid you are making a category error but perhaps that's in
>> part because I wasn't clear. I was not talking about computer
>> science. I was talking about human beings learning about computers.
On Wed, 4 Nov 2015 18:08:51 -0500, Terry Reedy
wrote:
>On 11/3/2015 10:23 PM, Steven D'Aprano wrote:
>
>> I don't even know what grep stands for.
>
>Get Regular Expression & Print
Thanks, I may get around to that eventually.
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 04 Nov 2015 14:48:21 +1100, Steven D'Aprano
wrote:
>On Wednesday 04 November 2015 11:33, ru...@yahoo.com wrote:
>
>>> Not quite. Core language concepts like ifs, loops, functions,
>>> variables, slicing, etc are the socket wrenches of the programmer's
>>> toolbox. Regexs are like an ele
On 11/3/2015 10:23 PM, Steven D'Aprano wrote:
I don't even know what grep stands for.
Get Regular Expression & Print
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 04 Nov 2015 08:13:51 -0700, Michael Torrie
wrote:
>On 11/04/2015 01:57 AM, Peter Otten wrote:
>> and then headed for the man page. Apparently there is a subset
>> called "basic regular expressions":
>>
>> """> Basic vs Extended Regular Expressions
>>In basic regular expressions
On 2015-11-04 09:57, Peter Otten wrote:
> Well, I didn't know that grep uses regular expressions by default.
It doesn't help that grep(1) comes in multiple flavors:
grep: should use BRE (Basic REs)
fgrep: same as "grep -F"; uses fixed strings, no REs
egrep: same as "grep -E"; uses ERE (Extende
On 2015-11-04 14:39, Steven D'Aprano wrote:
> On Wednesday 04 November 2015 03:56, Tim Chase wrote:
>> Or even more valuable to me:
>>
>> with open(..., newline="strip") as f:
>> assert all(not line.endswith(("\n", "\r")) for line in f)
>
> # Works only on Windows text files.
> def chomp(li
On 11/04/2015 01:57 AM, Peter Otten wrote:
> and then headed for the man page. Apparently there is a subset
> called "basic regular expressions":
>
> """> Basic vs Extended Regular Expressions
>In basic regular expressions the meta-characters ?, +, {, |, (,
>and ) lose their speci
On Thu, Nov 5, 2015 at 1:38 AM, rurpy--- via Python-list
wrote:
> I'm afraid you are making a category error but perhaps that's in
> part because I wasn't clear. I was not talking about computer
> science. I was talking about human beings learning about computers.
> Most people I know consider p
On Wednesday, November 4, 2015 at 1:52:31 AM UTC-7, Steven D'Aprano wrote:
> On Wednesday 04 November 2015 18:21, Christian Gollwitzer wrote:
>
> > What rurpy meant, was that regexes can surface to a computer user
> > earlier than variables and branches; a user who does not go into the
> > depth t
On 11/03/2015 08:48 PM, Steven D'Aprano wrote:
> On Wednesday 04 November 2015 11:33, rurpy wrote:
>
>>> Not quite. Core language concepts like ifs, loops, functions,
>>> variables, slicing, etc are the socket wrenches of the programmer's
>>> toolbox. Regexs are like an electric impact socket wre
On 2015-11-04, Michael Torrie wrote:
> On 11/03/2015 08:23 PM, Steven D'Aprano wrote:
>>
Grep can use regular expressions (and I do so with it regularly), but
it's default mode is certainly not regular expressions ...
>>>
>>> Its very name indicates that its default mode most certainly i
Op 04-11-15 om 04:35 schreef Steven D'Aprano:
> On Wednesday 04 November 2015 03:20, Chris Angelico wrote:
>
>> (So,
>> too, are all the comments about using [-1] or string methods. But we
>> weren't to know that.)
> If MRAB could understand what he wanted, I'm sure most others could have
> too.
On 4 November 2015 at 03:39, Steven D'Aprano
wrote:
>
> Better would be this:
>
> def chomp(lines):
> for line in lines:
> yield line.rstrip() # remove all trailing whitespace
>
>
> with open(...) as f:
> for line in chomp(f): ...
with open(...) as f:
for line in map(str.rstr
Michael Torrie wrote:
> On 11/03/2015 08:23 PM, Steven D'Aprano wrote:
Grep can use regular expressions (and I do so with it regularly), but
it's default mode is certainly not regular expressions ...
>>>
>>> Its very name indicates that its default mode most certainly is regular
>>> expr
On Wednesday 04 November 2015 18:21, Christian Gollwitzer wrote:
> What rurpy meant, was that regexes can surface to a computer user
> earlier than variables and branches; a user who does not go into the
> depth to actually program the machine, might still encounter them in a
> text editor or data
Am 04.11.15 um 04:48 schrieb Steven D'Aprano:
On Wednesday 04 November 2015 11:33, ru...@yahoo.com wrote:
Not quite. Core language concepts like ifs, loops, functions,
variables, slicing, etc are the socket wrenches of the programmer's
toolbox. Regexs are like an electric impact socket wrench
On Wed, 04 Nov 2015 14:23:04 +1100, Steven D'Aprano wrote:
>> Its very name indicates that its default mode most certainly is regular
>> expressions.
>
> I don't even know what grep stands for.
>From the ed command "g /re/p" (where "re" is a placeholder for an
arbitrary regular expression). Test
On Wednesday 04 November 2015 11:33, ru...@yahoo.com wrote:
>> Not quite. Core language concepts like ifs, loops, functions,
>> variables, slicing, etc are the socket wrenches of the programmer's
>> toolbox. Regexs are like an electric impact socket wrench. You can do
>> the same work without i
On 11/03/2015 08:23 PM, Steven D'Aprano wrote:
>>> Grep can use regular expressions (and I do so with it regularly), but
>>> it's default mode is certainly not regular expressions ...
>>
>> Its very name indicates that its default mode most certainly is regular
>> expressions.
>
> I don't even kno
On Wednesday 04 November 2015 03:56, Tim Chase wrote:
> Or even more valuable to me:
>
> with open(..., newline="strip") as f:
> assert all(not line.endswith(("\n", "\r")) for line in f)
# Works only on Windows text files.
def chomp(lines):
for line in lines:
yield line.rstrip(
On Wednesday 04 November 2015 03:20, Chris Angelico wrote:
> On Wed, Nov 4, 2015 at 3:10 AM, Seymore4Head
> wrote:
>> Yes I knew that -1 represents the end character. It is not a question
>> of trying to accomplish anything. I was just practicing with regex
>> and wasn't sure how to express a *
On Wednesday 04 November 2015 13:55, Dan Sommers wrote:
> On Tue, 03 Nov 2015 19:04:23 -0700, Michael Torrie wrote:
>
>> On 11/03/2015 05:33 PM, rurpy--- via Python-list wrote:
>>> I consider regexs more fundemental. One need not even be a programmer
>>> to use them: consider grep, sed, a zillio
On Wed, Nov 4, 2015 at 2:12 PM, Tim Chase wrote:
> It's not as helpful as one might hope because you're stuck using a
> fixed regexp rather than an arbitrary regexp, but if you have a
> particular regexp you search for frequently, you can index it.
> Otherwise, you'd be doing full table-scans (or
On 2015-11-03 19:04, Michael Torrie wrote:
> Grep can use regular expressions (and I do so with it regularly),
> but it's default mode is certainly not regular expressions, and it
> is still very powerful.
I suspect you're thinking of `fgrep` (AKA "grep -F") which uses fixed
strings rather than re
On Tue, 03 Nov 2015 19:04:23 -0700, Michael Torrie wrote:
> On 11/03/2015 05:33 PM, rurpy--- via Python-list wrote:
>> I consider regexs more fundemental. One need not even be a programmer
>> to use them: consider grep, sed, a zillion editors, database query
>> languages, etc.
>
> Grep can use
On 11/03/2015 05:33 PM, rurpy--- via Python-list wrote:
> I consider regexs more fundemental. One need not even be a programmer
> to use them: consider grep, sed, a zillion editors, database query
> languages, etc.
Grep can use regular expressions (and I do so with it regularly), but
it's defaul
On Monday, November 2, 2015 at 9:38:24 PM UTC-7, Michael Torrie wrote:
> On 11/02/2015 09:23 PM, rurpy--- via Python-list wrote:
> >> My completely unsolicited advice is that regular expressions shouldn't be
> >> very high on the list of things to learn. They are very useful, and very
> >> tricky
On 11/03/2015 12:15 AM, Steven D'Aprano wrote:
> On Tue, 3 Nov 2015 03:23 pm, rurpy wrote:
>
>> Regular expressions should be learned by every programmer or by anyone
>> who wants to use computers as a tool. They are a fundamental part of
>> computer science and are used in all sorts of matching
Am 03.11.2015 um 05:23 schrieb ru...@yahoo.com:
Of course there are people who misuse regexes.
/^1?$|^(11+?)\1+$/
There are? 0:-)
--
Robin Koch
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-11-03, Tim Chase wrote:
[re. iterating over lines in a file]
> I can't think of more than 1-2 times in my last 10+ years of
> Pythoning that I've actually had potential use for the newlines,
If you can think of 1-2 times when you've been interating over the
lines in a file and wanted to
On 2015-11-03 11:39, Ian Kelly wrote:
> >> because I have countless loops that look something like
> >>
> >> with open(...) as f:
> >> for line in f:
> >> line = line.rstrip('\r\n')
> >> process(line)
> >
> > What would happen if you read a file opened like this without
> > iter
On Tue, Nov 3, 2015 at 11:33 AM, Ian Kelly wrote:
> On Tue, Nov 3, 2015 at 9:56 AM, Tim Chase
> wrote:
>> Or even more valuable to me:
>>
>> with open(..., newline="strip") as f:
>> assert all(not line.endswith(("\n", "\r")) for line in f)
>>
>> because I have countless loops that look som
On Tue, Nov 3, 2015 at 9:56 AM, Tim Chase wrote:
> On 2015-11-03 16:35, Peter Otten wrote:
>> I wish there were a way to prohibit such files. Maybe a special
>> value
>>
>> with open(..., newline="normalize") f:
>> assert all(line.endswith("\n") for line in f)
>>
>> to ensure that all lines en
Tim Chase wrote:
> On 2015-11-03 16:35, Peter Otten wrote:
>> I wish there were a way to prohibit such files. Maybe a special
>> value
>>
>> with open(..., newline="normalize") f:
>> assert all(line.endswith("\n") for line in f)
>>
>> to ensure that all lines end with "\n"?
>
> Or even more
On 2015-11-03 16:35, Peter Otten wrote:
> I wish there were a way to prohibit such files. Maybe a special
> value
>
> with open(..., newline="normalize") f:
> assert all(line.endswith("\n") for line in f)
>
> to ensure that all lines end with "\n"?
Or even more valuable to me:
with open(
Peter Otten writes:
> Jussi Piitulainen wrote:
>> Peter Otten writes:
>>
>>> If a "line" is defined as a string that ends with a newline
>>>
>>> def ends_in_asterisk(line):
>>> return False
>>>
>>> would also satisfy the requirement. Lies, damned lies, and specs ;)
>>
>> Even if a "line" is d
On Wed, Nov 4, 2015 at 3:10 AM, Seymore4Head
wrote:
> Yes I knew that -1 represents the end character. It is not a question
> of trying to accomplish anything. I was just practicing with regex
> and wasn't sure how to express a * since it was one of the
> instructions.
In that case, it's nothin
On Tue, 3 Nov 2015 10:34:12 -0500, Joel Goldstick
wrote:
>On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head
>wrote:
>
>> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
>> wrote:
>>
>> >On 2015-11-02 20:09, Seymore4Head wrote:
>> >> How do I make a regular expression that returns true if the end of
>>
Jussi Piitulainen wrote:
> Peter Otten writes:
>
>> If a "line" is defined as a string that ends with a newline
>>
>> def ends_in_asterisk(line):
>> return False
>>
>> would also satisfy the requirement. Lies, damned lies, and specs ;)
>
> Even if a "line" is defined as a string that comes f
On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head
wrote:
> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> wrote:
>
> >On 2015-11-02 20:09, Seymore4Head wrote:
> >> How do I make a regular expression that returns true if the end of
> >> the line is an asterisk
> >
> >Why use a regular expression?
> >
Peter Otten writes:
> If a "line" is defined as a string that ends with a newline
>
> def ends_in_asterisk(line):
> return False
>
> would also satisfy the requirement. Lies, damned lies, and specs ;)
Even if a "line" is defined as a string that comes from reading
something like a file with d
On 2015-11-03, Tim Chase wrote:
> On 2015-11-02 20:09, Seymore4Head wrote:
>> How do I make a regular expression that returns true if the end of
>> the line is an asterisk
>
> Why use a regular expression?
>
> if line[-1] == '*':
Why use a negative index and then a compare?
if line.endswit
On 2015-11-02 22:17, Seymore4Head wrote:
> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> wrote:
>
> >On 2015-11-02 20:09, Seymore4Head wrote:
> >> How do I make a regular expression that returns true if the end
> >> of the line is an asterisk
> >
> >Why use a regular expression?
> >
> Because th
Tim Chase wrote:
> On 2015-11-03 10:25, Peter Otten wrote:
>> >>> How do I make a regular expression that returns true if the end
>> >>> of the line is an asterisk
>> >>
>> >> Why use a regular expression?
>> >>
>> >> if line[-1] == '*':
>> >> yep(line)
>> >> else:
>> >> nope(line)
>
On Mon, 02 Nov 2015 22:17:49 -0500, Seymore4Head wrote:
> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> wrote:
>
>>On 2015-11-02 20:09, Seymore4Head wrote:
>>> How do I make a regular expression that returns true if the end of the
>>> line is an asterisk
>>Why use a regular expression?
> Bec
On 2015-11-03 10:25, Peter Otten wrote:
> >>> How do I make a regular expression that returns true if the end
> >>> of the line is an asterisk
> >>
> >> Why use a regular expression?
> >>
> >> if line[-1] == '*':
> >> yep(line)
> >> else:
> >> nope(line)
>
> Incidentally the code exa
Michael Torrie wrote:
> On 11/02/2015 07:42 PM, Tim Chase wrote:
>> On 2015-11-02 20:09, Seymore4Head wrote:
>>> How do I make a regular expression that returns true if the end of
>>> the line is an asterisk
>>
>> Why use a regular expression?
>>
>> if line[-1] == '*':
>> yep(line)
>> el
On Tue, Nov 3, 2015 at 7:15 AM, Steven D'Aprano wrote:
> On Tue, 3 Nov 2015 03:23 pm, ru...@yahoo.com wrote:
>
> > Regular expressions should be learned by every programmer or by anyone
> > who wants to use computers as a tool. They are a fundamental part of
> > computer science and are used in
On Tue, 3 Nov 2015 03:23 pm, ru...@yahoo.com wrote:
> Regular expressions should be learned by every programmer or by anyone
> who wants to use computers as a tool. They are a fundamental part of
> computer science and are used in all sorts of matching and searching
> from compilers down to your
On 11/02/2015 09:23 PM, rurpy--- via Python-list wrote:
>> My completely unsolicited advice is that regular expressions shouldn't be
>> very high on the list of things to learn. They are very useful, and very
>> tricky and prone many problems that can and should be learned to be
>> resolved with m
On 11/02/2015 09:23 PM, rurpy--- via Python-list wrote:
> On 11/02/2015 08:51 PM, Michael Torrie wrote:
>> [...]
>> Indeed, sometimes Jamie Zawinski's is often quite appropriate:
>>
>> Some people, when confronted with a problem, think "I know, I'll use
>> regular expressions." Now they have tw
On Monday, November 2, 2015 at 8:58:45 PM UTC-7, Joel Goldstick wrote:
> On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head
> wrote:
>
> > On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> > wrote:
> >
> > >On 2015-11-02 20:09, Seymore4Head wrote:
> > >> How do I make a regular expression that returns t
On 11/02/2015 08:51 PM, Michael Torrie wrote:
>[...]
> Indeed, sometimes Jamie Zawinski's is often quite appropriate:
>
> Some people, when confronted with a problem, think "I know, I'll use
> regular expressions." Now they have two problems.
Or its sometimes heard paraphrase:
Some people,
On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head
wrote:
> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> wrote:
>
> >On 2015-11-02 20:09, Seymore4Head wrote:
> >> How do I make a regular expression that returns true if the end of
> >> the line is an asterisk
> >
> >Why use a regular expression?
> >
On 11/02/2015 07:42 PM, Tim Chase wrote:
> On 2015-11-02 20:09, Seymore4Head wrote:
>> How do I make a regular expression that returns true if the end of
>> the line is an asterisk
>
> Why use a regular expression?
>
> if line[-1] == '*':
> yep(line)
> else:
> nope(line)
Indeed, some
On Tue, 3 Nov 2015 01:19:34 +, MRAB
wrote:
>On 2015-11-03 01:09, Seymore4Head wrote:
>> How do I make a regular expression that returns true if the end of the
>> line is an asterisk
>>
>To match an asterisk: \*
>
>To match the end of a line: $
>
>To match an asterisk at the end of a line: \*$
On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
wrote:
>On 2015-11-02 20:09, Seymore4Head wrote:
>> How do I make a regular expression that returns true if the end of
>> the line is an asterisk
>
>Why use a regular expression?
>
> if line[-1] == '*':
>yep(line)
> else:
>nope(line)
>
>-tkc
On 2015-11-02 20:09, Seymore4Head wrote:
> How do I make a regular expression that returns true if the end of
> the line is an asterisk
Why use a regular expression?
if line[-1] == '*':
yep(line)
else:
nope(line)
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-11-03 01:09, Seymore4Head wrote:
How do I make a regular expression that returns true if the end of the
line is an asterisk
To match an asterisk: \*
To match the end of a line: $
To match an asterisk at the end of a line: \*$
--
https://mail.python.org/mailman/listinfo/python-list
1 - 100 of 299 matches
Mail list logo