| OT: Regexp [message #788468] |
Fri, 21 July 2006 01:43 |
|
I need a crash course on "knowing" regular expressions. Can anyone give me a
pointer towards a FOAK? I have three hours tomorrow morning to become
reasonably knowledgeable .
Thanks
|
|
|
| Re: Regexp [message #788470 ] |
Fri, 21 July 2006 01:54 |
|
"elyob" <newsprofile [at] gmail.com> wrote in message
news:44c0151c$1 [at] news1.homechoice.co.uk...
>I need a crash course on "knowing" regular expressions. Can anyone give me
>a pointer towards a FOAK? I have three hours tomorrow morning to become
>reasonably knowledgeable .
>
I'd never heard of them till I looked at your post but this looks useful:
http://www.regular-expressions.info/
I'm guessing that you prolly found this already but figured that you might
not get a lot of other replies this late.
|
|
|
| Re: Regexp [message #788471 ] |
Fri, 21 July 2006 02:00 |
|
"the man with no idea" <no.spam [at] thanks> wrote in message
news:0JUvg.16346$v02.6020 [at] newsfe3-gui.ntli.net...
>
> "elyob" <newsprofile [at] gmail.com> wrote in message
> news:44c0151c$1 [at] news1.homechoice.co.uk...
>>I need a crash course on "knowing" regular expressions. Can anyone give me
>>a pointer towards a FOAK? I have three hours tomorrow morning to become
>>reasonably knowledgeable .
>>
> I'd never heard of them till I looked at your post but this looks useful:
>
> http://www.regular-expressions.info/
>
> I'm guessing that you prolly found this already but figured that you might
> not get a lot of other replies this late.
I've had my 'head stuck in books' [1], and hadn't seen that.
Thanks for the link.
Nick
[1] went to the pub, it's too hot for studying. Tennis beckoned.
|
|
|
| Re: OT: Regexp [message #788472 ] |
Fri, 21 July 2006 01:57 |
|
elyob wrote
>I need a crash course on "knowing" regular expressions. Can anyone give me a
>pointer towards a FOAK? I have three hours tomorrow morning to become
>reasonably knowledgeable .
Keep it topical is always good advice for interviews. I believe the
tern "yo blair" is set to become quite fashionable in certain quarters.
--
steve auvache
i rate dates
|
|
|
| Re: OT: Regexp [message #788473 ] |
Fri, 21 July 2006 02:02 |
|
elyob <newsprofile [at] gmail.com> wrote:
> I need a crash course on "knowing" regular expressions. Can anyone give me a
> pointer towards a FOAK? I have three hours tomorrow morning to become
> reasonably knowledgeable .
>
They're trivial (www.regular-expressions.info) as even a half arsed web
search would have shown.
|
|
|
| Re: OT: Regexp [message #788499 ] |
Fri, 21 July 2006 09:39 |
|
On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
<Simon [at] invalid.semi-evolved.org> wrote:
>elyob <newsprofile [at] gmail.com> wrote:
>> I need a crash course on "knowing" regular expressions. Can anyone give me a
>> pointer towards a FOAK? I have three hours tomorrow morning to become
>> reasonably knowledgeable .
>>
>
>They're trivial (www.regular-expressions.info)
That's a great example of how *nix-type geeks can make a simple
concept confusing. I never cease to be amazed by how appallingly bad
many tachies are about understanding how little other people will be
able to understand their explanations. One of my colleagues tried to
teach our (SAS) programmers some regexp stuff a couple of years ago,
but practically none of them understood anything beyond *.
To say that they're trivial is, well, 'wrong', I guess, is the only
word that fits. They're hugely powerful, _in some situations_ but
their appearance can reduce many experienced computer users to jelly
in an instant.
--
_______
..'_/_|_\_'. Ace (brucedotrogers a.t rochedotcom)
\`\ | /`/ GSX-R1000K3
`\\ | //' BOTAFOT#3, SbS#2, UKRMMA#13, DFV#8, SKA#2, IBB#10
`\|/`
`
|
|
|
| Re: OT: Regexp [message #788515 ] |
Fri, 21 July 2006 10:06 |
|
Ace wrote:
> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
> <Simon [at] invalid.semi-evolved.org> wrote:
>
> >elyob <newsprofile [at] gmail.com> wrote:
> >> I need a crash course on "knowing" regular expressions. Can anyone give me a
> >> pointer towards a FOAK? I have three hours tomorrow morning to become
> >> reasonably knowledgeable .
> >>
> >
> >They're trivial (www.regular-expressions.info)
>
>They're hugely powerful, _in some situations_ but
> their appearance can reduce many experienced computer users to jelly
> in an instant.
>
<waves>
Though I only use them in my .htaccess file to redirect leeching
requests for my ebay images. :)
--
John
'00 SV650S
|
|
|
| Re: OT: Regexp [message #788704 ] |
Fri, 21 July 2006 17:20 |
|
"Higgins [at] work" <the.best.names.are.gone [at] gmail.com> wrote in message
news:1153469196.701322.200280 [at] m79g2000cwm.googlegroups.com...
>
> Ace wrote:
>> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
>> <Simon [at] invalid.semi-evolved.org> wrote:
>>
>> >elyob <newsprofile [at] gmail.com> wrote:
>> >> I need a crash course on "knowing" regular expressions. Can anyone
>> >> give me a
>> >> pointer towards a FOAK? I have three hours tomorrow morning to become
>> >> reasonably knowledgeable .
>> >>
>> >
>> >They're trivial (www.regular-expressions.info)
>>
>>They're hugely powerful, _in some situations_ but
>> their appearance can reduce many experienced computer users to jelly
>> in an instant.
>>
>
> <waves>
>
> Though I only use them in my .htaccess file to redirect leeching
> requests for my ebay images. :)
Thanks to all, I read through quite a lot of that regular-expressions.info
and that was very useful. Didn't get asked a single technical question this
afternoon, damn. Oh well, back again Tuesday for a technical test so puts me
in good stead. Looks like a weekend of revision for me then.
|
|
|
| Re: OT: Regexp [message #788816 ] |
Fri, 21 July 2006 23:12 |
|
Ace wrote:
> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
> <Simon [at] invalid.semi-evolved.org> wrote:
>
> >elyob <newsprofile [at] gmail.com> wrote:
> >> I need a crash course on "knowing" regular expressions. Can anyone give me a
> >> pointer towards a FOAK? I have three hours tomorrow morning to become
> >> reasonably knowledgeable .
> >>
> >
> >They're trivial (www.regular-expressions.info)
>
> That's a great example of how *nix-type geeks can make a simple
> concept confusing. I never cease to be amazed by how appallingly bad
> many tachies are about understanding how little other people will be
> able to understand their explanations. One of my colleagues tried to
> teach our (SAS) programmers some regexp stuff a couple of years ago,
> but practically none of them understood anything beyond *.
>
> To say that they're trivial is, well, 'wrong', I guess, is the only
> word that fits. They're hugely powerful, _in some situations_ but
> their appearance can reduce many experienced computer users to jelly
> in an instant.
Here is a nice one if you have need of convincing
that it is not necessarily easy.
# $np defines a brace matching pattern.
# Matches from the first opening brace (I guess) to it's
# matching closing brace. I have only tested it with an opening
# brace as the first character in the string.
# So - when applied to "(a(b)c)d)e)" it matches "(a(b)c)".
#
$np = qr{
\(
(?:
(?> [^()]+ ) # Non-parens without backtracking
|
(??{ $np }) # Group with matching parens
)*
\)
}x;
$mystring = "(a(b)c)d)e)";
$mystring =~ $np;
print $&; # prints "(a(b)c)"
I managed to use this in some perl code without
having the faintest clue how it worked. Still don't
have clue.
Found on net somewhere. Thanks interweb.
|
|
|
| Re: OT: Regexp [message #788823 ] |
Fri, 21 July 2006 23:21 |
|
On Fri, 21 Jul 2006 09:39:28 +0200, Ace wrote:
> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
> <Simon [at] invalid.semi-evolved.org> wrote:
<SNIP Regular expresions>
>>They're trivial (www.regular-expressions.info)
>
> That's a great example of how *nix-type geeks can make a simple concept
> confusing.<snip>
> To say that they're trivial is, well, 'wrong', I guess, is the only word
> that fits. They're hugely powerful, _in some situations_ but their
> appearance can reduce many experienced computer users to jelly in an
> instant.
I think you're right that they're not trivial. I don't think they're
especially complex, but they *are* something you need to actually practice
with for a while to get a graps of.
--
Simon - UKRM~verdigris,plus,com
Tiger - A return to good sense.
Z1000 - Less sense, more sensation.
MAG BOTAFOT#36 two#22 HLR#pi BONY#62 BHaLC#3 LotR#7
|
|
|
| Re: OT: Regexp [message #788829 ] |
Fri, 21 July 2006 23:47 |
|
Verdigris wrote
>On Fri, 21 Jul 2006 09:39:28 +0200, Ace wrote:
>
>> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
>> <Simon [at] invalid.semi-evolved.org> wrote:
>
><SNIP Regular expresions>
>
>>>They're trivial (www.regular-expressions.info)
>>
>> That's a great example of how *nix-type geeks can make a simple concept
>> confusing.<snip>
>
>> To say that they're trivial is, well, 'wrong', I guess, is the only word
>> that fits. They're hugely powerful, _in some situations_ but their
>> appearance can reduce many experienced computer users to jelly in an
>> instant.
>
>I think you're right that they're not trivial. I don't think they're
>especially complex,
Depends on the expression dunnit. Context is everything
>but they *are* something you need to actually practice
>with for a while to get a graps of.
When I was doing it we introduced this shit at the back end of the
fundies course and as instructors we used to use it to keep the nerdy
types quiet onna friday while we helped the stragglers come to grips
with whatever was causing them issues from earlier in the week.
Later they moved it to Admin 1, which was a move generally applauded by
all of us instructors.
For all I know they have moved it back again now but it has to be said
that not everybody can get well to grips with it but how you start and
where you start from makes a huge difference.
--
steve auvache
i rate dates
|
|
|
| Re: OT: Regexp [message #788872 ] |
Sat, 22 July 2006 01:40 |
|
Ace <seesig [at] virgin.net> wrote:
> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
>>>
>>
>>They're trivial (www.regular-expressions.info)
>
> To say that they're trivial is, well, 'wrong', I guess, is the only
> word that fits. They're hugely powerful, _in some situations_ but
> their appearance can reduce many experienced computer users to jelly
> in an instant.
'computer users' - heh. Why would they need regexp?
|
|
|
| Re: OT: Regexp [message #788884 ] |
Sat, 22 July 2006 02:46 |
|
anybody43 [at] hotmail.com <anybody43 [at] hotmail.com> wrote:
> Ace wrote:
>> On Fri, 21 Jul 2006 00:02:55 -0000, Simon Gates
>
> $np = qr{
> \(
> (?:
> (?> [^()]+ ) # Non-parens without backtracking
> |
> (??{ $np }) # Group with matching parens
> )*
> \)
> }x;
>
> I managed to use this in some perl code without
> having the faintest clue how it worked. Still don't
> have clue.
> Found on net somewhere. Thanks interweb.
That's not 'regexp' that a recursive perl pattern which uses regexp.
qr{...}x = compile this regexp, ignoring whitespace
\( = match an open bracket
\) = match a close bracket
(?> [^()]+) = match everything that exists, that's not a round
bracket, ending matching on first fail
(??{ $np }) = embed defined perl pattern $np (i.e. itself)
( ( ... ) | ( ... ) )*
= match the contents of either the first or second set of
brackets as often as either of them occurs, or not at all
So, match a '(' followed by zero or more '()' pairs, ignoring anything
that's not a '(' or ')', folowed by a ')'.
The difficult part of that is it's recursiveness, not the regexp.
|
|
|