Albert-Jan Roskam wrote:
> Nice solution indeed! Will it also work with accented characters? And how
> should one incorporate the collating sequence into the solution? By
> explicitly setting the locale? It might be nice if the outcome is always
> the same, whereever you are in the world.
This is
?
~~
>
>From: Terry Carroll
>To: tutor@python.org
>Sent: Sunday, November 6, 2011 8:21 PM
>Subject: Re: [Tutor] regexp
>
>On Sat, 5 Nov 2011, Dinara Vakhitova wrote:
>
>> I need to find the words in a corpus, which l
Asokan Pichai wrote:
> IMO the regex is not too bad; I will not use it for this job -- typing
> a 50+ character string
> is more painful (and more error prone) than writing 5--10 lines of code.
Well, you can build the string programmatically:
>>> "*".join(string.ascii_lowercase) + "*"
'a*b*c*d*e
IMO the regex is not too bad; I will not use it for this job -- typing
a 50+ character string
is more painful (and more error prone) than writing 5--10 lines of code.
That said, if it made you look at regexes deeply and beyond the simple
explanation
of what each character (*, ., +) does I think th
Dear Terry,
Thank you for your advise, I'll try to implement it.
D.
2011/11/6 Terry Carroll
> On Sat, 5 Nov 2011, Dinara Vakhitova wrote:
>
> I need to find the words in a corpus, which letters are in the
>> alphabetical
>> order ("almost", "my" etc.)
>> I started with matching two consecutiv
On Sat, 5 Nov 2011, Dinara Vakhitova wrote:
I need to find the words in a corpus, which letters are in the alphabetical
order ("almost", "my" etc.)
I started with matching two consecutive letters in a word, which are in
the alphabetical order, and tried to use this expression: ([a-z])[\1-z], but
Oh, sorry, of course it should be without brackets: 'a*b*c*...'
> [a*b*c*d*...x*y*z*]
2011/11/5 Dinara Vakhitova
> Steven, Walter, Dave, Peter and Albert,
>
> First of all, thank you very much for your suggestions, I appreciate a lot
> your help. I would only like to mention that I would have
Steven, Walter, Dave, Peter and Albert,
First of all, thank you very much for your suggestions, I appreciate a lot
your help. I would only like to mention that I would have never asked
something to be done for me just because it's my homework, I posted this
question only because I couldn't find a
___
>From: Dave Angel
>To: Steven D'Aprano
>Cc: tutor@python.org
>Sent: Saturday, November 5, 2011 2:49 AM
>Subject: Re: [Tutor] regexp
>
>On 11/04/2011 07:00 PM, Steven D'Aprano wrote:
>> Dinara Vakhitova wrote:
>>> Hello,
>>>
>
Steven D'Aprano wrote:
> Good luck with the question! If you do solve it, please come back and
> tell us how you did it. I for one am curious now whether or not it can
> be done using Python regexes. Perhaps someone else might have a
> solution. You could try the python-l...@python.org mailing lis
On 11/04/2011 07:00 PM, Steven D'Aprano wrote:
Dinara Vakhitova wrote:
Hello,
I need to find the words in a corpus, which letters are in the
alphabetical
order ("almost", "my" etc.)
Quoting Jamie Zawinski:
Some people, when confronted with a problem, think "I know, I'll
use regular
Dinara, Steven,
On 4 November 2011 23:29, Steven D'Aprano wrote:
> Is this homework? You should have said so.
>
Inded he should've...
> I don't understand questions like this. Do carpenters ask their
> apprentices to cut a piece of wood with a hammer? Do apprentice chefs get
> told to dice ca
Dinara Vakhitova wrote:
Sorry, I didn´t know that I couldn´t ask questions about the homework...
You're welcome to ask questions about homework or school projects, but
most of the people here believe that ethically the student should do the
homework, not the tutor :)
So if something looks
On 5 November 2011 00:38, Dinara Vakhitova wrote:
> Sorry, I didn´t know that I couldn´t ask questions about the homework...
This list is meant to help with learning python and not to do
homework assignments. So if you get stuck with something yes you can
post it but be open about it and show wh
Sorry, I didn´t know that I couldn´t ask questions about the homework...
I wanted to do it recursively, like this:
def check_abc(string):
string = string.lower()
check_pair = re.compile("([a-z])[\1-z]")
if check_pair.match(string):
if check_abc(string[1:]):
return T
Dinara Vakhitova wrote:
Thank you for your answer, Steven.
Of course it would have been easier to write this function,
but unfortunately my task is to do it with a regular expression :(
Is this homework? You should have said so.
I don't understand questions like this. Do carpenters ask their
Thank you for your answer, Steven.
Of course it would have been easier to write this function,
but unfortunately my task is to do it with a regular expression :(
D.
2011/11/5 Steven D'Aprano
> Dinara Vakhitova wrote:
>
>> Hello,
>>
>> I need to find the words in a corpus, which letters are in
Dinara Vakhitova wrote:
Hello,
I need to find the words in a corpus, which letters are in the alphabetical
order ("almost", "my" etc.)
Quoting Jamie Zawinski:
Some people, when confronted with a problem, think "I know, I'll
use regular expressions." Now they have two problems.
Now yo
On 10/1/10, Steven D'Aprano wrote:
> On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote:
>> >> Here is my test:
>> >> s=re.search(r"[\d+\s+\d+\s+\d]", l)
>> >
>> > Try this instead:
>> >
>> > re.search(r'\d+\s+\D*\d+\s+\d', l)
> [...]
>> Understood. My intent was to ask why my regexp would match anyth
On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote:
> >> Here is my test:
> >> s=re.search(r"[\d+\s+\d+\s+\d]", l)
> >
> > Try this instead:
> >
> > re.search(r'\d+\s+\D*\d+\s+\d', l)
[...]
> Understood. My intent was to ask why my regexp would match anything
> at all.
Square brackets create a charact
On 10/1/10, Steven D'Aprano wrote:
> On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote:
>> Hi, once again...
>> I have a regexp that I am trying to use to make sure a line matches
>> the format: [c*]n [c*]n n
>> where c* is (optionally) 0 or more non-numeric characters and n is
>> any numeric charact
with coffee:
yes = """
v1 v2 5
2 someword7 3
""".splitlines()[1:]
no = """
word 2 3
1 2
""".splitlines()[1:]
import re
pattern = "(\w*\d\s+?)(\w*\d\s+?)(\d)$"
rx = re.compile(pattern)
for line in yes:
m = rx.match(line)
assert m
print([part.rstrip() for part in m.groups()])
f
On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote:
> Hi, once again...
> I have a regexp that I am trying to use to make sure a line matches
> the format: [c*]n [c*]n n
> where c* is (optionally) 0 or more non-numeric characters and n is
> any numeric character. The spacing should not matter. These sh
Alex Hall wrote:
Hi, once again...
I have a regexp that I am trying to use to make sure a line matches the format:
[c*]n [c*]n n
where c* is (optionally) 0 or more non-numeric characters and n is any
numeric character. The spacing should not matter. These should pass:
v1 v2 5
2 someword7 3
whi
Hi Kent,
thanks your respond.
> > I have to remove the thousand separator by moving the numbers before
it to
> > right.
> > So the number and char groups has to be left in their original
position.
> >
> > I have to make this kind of changes on the problematic lines:
> > MOATOT79 47.2
János Juhász wrote:
> Dear All,
>
> I have a problem about the EDI invoices created by our erp system.
> I have to make a small correction on them, just before sending them by
> ftp.
>
> The problem is that, the big numbers are printed with thousand separator.
>
> U:\ediout\INVOIC\Backup>grep \
Kristian Evensen wrote:
> What I want to do is to check for two patterns to make sure all
> occurrences of pattern1 and pattern2 come in the same order as they do
> in the file I parse. It it contains a number of computer-games I would
> like the output to look something like this:
>
> PC, Batt
On Tue, 14 Dec 2004, Gooch, John wrote:
> I am used to ( in Perl ) the entire string being searched for a match
> when using RegExp's. I assumed this was the way Python would do it do,
> as Java/Javascript/VbScript all behaved in this manner. However, I found
> that I had to add ".*" in front of
To: Gooch, John
Cc: '[EMAIL PROTECTED]'
Subject: Re: [Tutor] Regexp Not Matching on Numbers?
I'm not too sure what you are trying to do here, but the re in your code
matches the names in your
example data:
>>> import re
>>> name = 'partners80_access_lo
Max Noel wrote:
On Dec 14, 2004, at 18:15, Gooch, John wrote:
So far I have tried the following regular
expressions:
"\d+"
"\d*"
"\W+"
"\W*"
"[1-9]+"
and more...
I think you have to escape the backslashes.
or use raw strings like r"\d+" which is what is in the sample code...
Kent
_
I'm not too sure what you are trying to do here, but the re in your code matches the names in your
example data:
>>> import re
>>> name = 'partners80_access_log.1102723200'
>>> re.compile(r"([\w]+)").match( name ).groups()
('partners80_access_log',)
One thing that may be tripping you up is that r
On Dec 14, 2004, at 18:15, Gooch, John wrote:
This is weird. I have a script that checks walks through directories,
checks
to see if their name matches a certain format ( regular expression ),
and
then prints out what it finds. However, it refuses to ever match on
numbers
unless the regexp is ".
32 matches
Mail list logo