Can't get group to match - please help

J

jack

This seemingly simple regex is causing me problems

my $test = "Pub LOC.REC.USEIB03375MAR09.mngref0 #010C9D94";
my ($res) = ($test =~ /Pub (\w+{\.\w+})\s#.*/);
if( $res ){
print "\n$res\n";
}


The problem is to extract the "LOC.REC.USEIB03375MAR09.mngref0" part of
the string, which may have three to six parts - so it could be
LOC.REC.USEIB03375MAR09 or it could be
LOC.REC.USEIB03375MAR09.mngref0.day9.test


What am I doing wrong ??
 
A

Anno Siegel

This seemingly simple regex is causing me problems

my $test = "Pub LOC.REC.USEIB03375MAR09.mngref0 #010C9D94";
my ($res) = ($test =~ /Pub (\w+{\.\w+})\s#.*/);
if( $res ){
print "\n$res\n";
}


The problem is to extract the "LOC.REC.USEIB03375MAR09.mngref0" part of
the string, which may have three to six parts - so it could be
LOC.REC.USEIB03375MAR09 or it could be
LOC.REC.USEIB03375MAR09.mngref0.day9.test


What am I doing wrong ??

Hard to say. I don't really see what parts of your regex you expect
what parts of the string to match. For a start, your regex tries to
match a "{" and later a "}", but neither are in your string.

Anno
 
J

jack

OK, I realise that I completely misinterpreted what the '{' and '}' are
for.

So, how do I indicate that I am interested in 1 or more "\.\w"
occurances ?

In other words, how do I get the '+' to apply to a - dot '\.' -
followed by a word '\w+'

How do I treat '\.' and '\w' as a single unit ?
 
A

Anno Siegel

[no context, no attribution]
OK, I realise that I completely misinterpreted what the '{' and '}' are
for.

So, how do I indicate that I am interested in 1 or more "\.\w"
occurances ?

As far as I remember, you aren't interested in that but in one or
more groups /\.\w+/.

Anyway, read up on regular expressions, especially about the '+'
quantifier.
In other words, how do I get the '+' to apply to a - dot '\.' -
followed by a word '\w+'

How do I treat '\.' and '\w' as a single unit ?

They are. For larger groups, see non-capturing groups and/or non-capturing
parentheses in perlre.

Anno
 
J

jack

Actually, the simple answer to my question would have been:

Read about the use of parenthesis without triggering memory, in other
words /(?:expression)/

So the solution to my problem is

my $test = "Pub LOC.REC.USEIB03375MAR09.mngref0 #010C9D94";
my ($res) = ($test =~ /Pub (\w+(?:\.\w+)+)\s#.*/);
if( $res ){
print "\n$res\n";
}

Of course the fact that it took re-reading the same section of the perl
documentation about ten times to notice it is my fault.
 
A

Anno Siegel

[no attribution, no context, again]

You're showing a learning rate of zero. Please learn how to post
properly.
Actually, the simple answer to my question would have been:

Read about the use of parenthesis without triggering memory, in other
words /(?:expression)/

Yes, I've given that answer (you snipped it):

What are you going on about?

Anno
 
J

jack

[no attribution, no context, again]

Well, Thank you, I guess ?!?!?
How strange you should say that, I've already learned to not like you.
Oh, great wise sage of comp.lang.perl.misc please help me to gain the
requisite knowledge

I find this to be a very strange conversation. You claim to have given
me the answer, yet when I review your first two postings neither
contains /(?:expression)/
Your lack of helpfulness, and asinine attitude
 
A

A. Sinan Unur

(e-mail address removed) wrote in
(e-mail address removed)-berlin.de (Anno Siegel) wrote in
[no attribution, no context, again]

Well, Thank you, I guess ?!?!?

You should have thanked Anno, learned from your mistake, and moved on.

....
Your lack of helpfulness, and asinine attitude

Don't consider the lack of response from others in this group to be a
tacit approval of your style. Anno was the only person who took time to
try to help. After your responses, I do not think that number is going
to go up substantially.

Bye.

Sinan
 
A

Anno Siegel

[no attribution, no context, again]

Well, Thank you, I guess ?!?!?
How strange you should say that, I've already learned to not like you.
Oh, great wise sage of comp.lang.perl.misc please help me to gain the
requisite knowledge

Read the posting guidelines. They appear here regularly.
I find this to be a very strange conversation. You claim to have given
me the answer, yet when I review your first two postings neither
contains /(?:expression)/

Right, they *deliberately* don't contain that. They do contain the words
"non-capturing group". Learn to read for comprehension.
Your lack of helpfulness, and asinine attitude

My lack of helpfulness reflects your inability or unwillingness to
conduct a coherent Usenet conversation. What you think about that
is of little concern.

Anno
 
P

Paul Lalli

[no attribution, no context, again]

Well, Thank you, I guess ?!?!?

Do you see four lines up? Where it says "(e-mail address removed)
wrote:"? That's an attribution. That has been the custom and
tradition in Usenet for decades. That's one of the things you keep
snipping.

Do you see three lines below that? Where it says "> Well, Thank you, I
guess ?!?!?"? That's context. That lets people reading this message
know what I'm replying to. That also has been custom and tradition for
decades. That's the other thing you keep snipping. Apologize, correct
yourself, and move on.
How strange you should say that, I've already learned to not like you.

How very foolish of you.
Oh, great wise sage of comp.lang.perl.misc please help me to gain the
requisite knowledge

It requires neither greatness nor wisdom to read the posting guidelines
that are posted to this group twice a week, every week. Go. Read
them.
I find this to be a very strange conversation. You claim to have given
me the answer, yet when I review your first two postings neither
contains /(?:expression)/

I find it fascinating that in reply to the Anno's telling you that you
snipped his answer, you snipped it again, and then claimed that he
never gave it to you. He said:

That *is* the answer. Or were you upset that he did not hand feed you
the solution, that he did not say "Put your expression inside a (?: )
construct, because this is a non-capturing parenthesized group"? He
directed you to the exact phrase to look for in the exact document to
read. You are upset that he told you how and where to fish, rather
than gave you one?
Your lack of helpfulness, and asinine attitude

He has been very helpful, both in this thread, and in countless others.
Yours is sadly the only asinine attitude on display here.

Paul Lalli
 
J

jack

Paul said:
[no attribution, no context, again]

Well, Thank you, I guess ?!?!?

Do you see four lines up? Where it says "(e-mail address removed)
wrote:"? That's an attribution. That has been the custom and
tradition in Usenet for decades. That's one of the things you keep
snipping.

Well, I've been reading, posting questions and answering quesitons in
news groups 'for decades' and this is the *first* thread I have ever
been involved with where someone has ever commented upon that. I guess
it really is always September..
Do you see three lines below that? Where it says "> Well, Thank you, I
guess ?!?!?"? That's context. That lets people reading this message
know what I'm replying to. That also has been custom and tradition for
decades. That's the other thing you keep snipping. Apologize, correct
yourself, and move on.

You want me to apologize for having someone tell me that I have a
learning rate of zero ? That was meant as an insult, whether it is
true or not.
How very foolish of you.

Perhaps, but a very predicatble and understandable reaction to be
insulted.
It requires neither greatness nor wisdom to read the posting guidelines
that are posted to this group twice a week, every week. Go. Read
them.

Gosh, I didn't realise that it was a requirement to read and obey all
the posting guidelines. Actually it's quite odd - I had no idea such
guidlines existed - but now after having read them I'm sure I recall
something about "...poster is unaware ...".
I find it fascinating that in reply to the Anno's telling you that you
snipped his answer, you snipped it again, and then claimed that he
never gave it to you. He said:


That *is* the answer. Or were you upset that he did not hand feed you
the solution, that he did not say "Put your expression inside a (?: )
construct, because this is a non-capturing parenthesized group"? He
directed you to the exact phrase to look for in the exact document to
read. You are upset that he told you how and where to fish, rather
than gave you one?

Actually I wasn't upset, just confused, as I imagine many newbies to
perl would be when encountering this:
as opposed to, say:

See: /(?:expression)/

or perhaps:

You can group terms with a /(?:terms)/ - note the ? and : characters
within the parentheses. see the documentation entitled "non-capturing
groups" or "non-capturing parentheses"

This would explain the use of the relatively technical term '
non-capturing', which I might not be familiar with (and in fact I
wasn't - so unfamiliar was I that it didn't even register as a
technical term, so unfamiliar I didn't realise that 'perlre' was a
document reference, rather I guessed it was a typo, and as a result
couldn't figure out what the suggestion meant at all. )
He has been very helpful, both in this thread, and in countless others.
Yours is sadly the only asinine attitude on display here.

Paul Lalli

Perhaps, but In my opinion his superiority complex got the better of
him this time., and I have noticed it in other posts of his within this
group as well.
 
P

Paul Lalli

You want me to apologize for having someone tell me that I have a
learning rate of zero ?

No, I want you to apologize to anyone else reading these messages for
making it harder to follow the thread, by not quoting context, and by
not attributing.
Gosh, I didn't realise that it was a requirement to read and obey all
the posting guidelines. Actually it's quite odd - I had no idea such
guidlines existed

Meaning that you found this newsgroup, and decided to dig right in and
post without bothering to search any of the archives or read the last
few days worth of posts - or even the last few days worth of subject
headings? That is what is meant by "needs a better Kindegarden". A
means by which people are told how to not be rude when they encounter a
new environment.
- but now after having read them I'm sure I recall
something about "...poster is unaware ...".

Yes, you did. Specifically:
A note to newsgroup "regulars":

Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume

No where were you flamed for your *original* infraction. It was only
after this infraction was pointed out to you, and that you continued to
not alter your methods, were you "insulted".
Actually I wasn't upset, just confused, as I imagine many newbies to
perl would be when encountering this:

Okay. You were confused. That's actually pretty understandable. And
yet, rather than asking for clarification, you simply made an
accusation that someone was unhelpful and never gave you any answers.
This would explain the use of the relatively technical term '
non-capturing', which I might not be familiar with (and in fact I
wasn't - so unfamiliar was I that it didn't even register as a
technical term, so unfamiliar I didn't realise that 'perlre' was a
document reference, rather I guessed it was a typo, and as a result
couldn't figure out what the suggestion meant at all. )

Again - if you're confused by a response, you should ask about that
response. You didn't know what "perlre" was? Why didn't you simply
ask "What do you mean by 'perlre'?" You quite likely would have gotten
a helpful pointer to the perl documentation, at which point you could
have read and searched for the phrase "non-capturing". Instead, you
just snipped the portions you didn't understand, and claimed that no
one is being helpful.

Paul Lalli
 
J

jack

Paul said:
No, I want you to apologize to anyone else reading these messages for
making it harder to follow the thread, by not quoting context, and by
not attributing.

OK, how do I do that ?

It seems to me that *you* can follow this thread just fine, and
appearantly I haven't taken the requisite steps for you do to so,
please explain.

Meaning that you found this newsgroup, and decided to dig right in and
post without bothering to search any of the archives or read the last
few days worth of posts - or even the last few days worth of subject
headings? That is what is meant by "needs a better Kindegarden". A
means by which people are told how to not be rude when they encounter a
new environment.

Actually I did do a search in the three perl reference books I have
access to "Learning Perl", "Programming Perl", and "Perl in a
Nutshell"; all O'Reilly books, as well as reviewing several posting in
this newsgroup.

As I have stated, I missed the sentence which discussed using the
/(?:expression)/ syntax.
I realise now why that is, and it is because /(expression)/ would
appear to have 'used up' the use of parentheses as a grouping operator.
I would never have imagined that they would be reused with the aid of
a ? and :
Yes, you did. Specifically:
A note to newsgroup "regulars":

Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume

No where were you flamed for your *original* infraction. It was only
after this infraction was pointed out to you, and that you continued to
not alter your methods, were you "insulted".

Hmm...
The first time I have *ever* seen "[no context, no attribution]" used
in a newgroup posting was Anno's response. When I saw it I wasn't even
sure if he had written it, or if it was somehow automatically inserted
by whatever software he was using to post to the newsgroup. Nor did I
understand that it had *any* significance. Since my initial impression
was that it was a software generated sequence of garbage I did the
polite thing and ignored it.
Okay. You were confused. That's actually pretty understandable. And
yet, rather than asking for clarification, you simply made an
accusation that someone was unhelpful and never gave you any answers.

Hmm.. I guess I understand part of the problem. Anno interpreted this
sentence:to be critical of his help. I guess it does sound critical, although
wasn't really meant to be so.
Again - if you're confused by a response, you should ask about that
response. You didn't know what "perlre" was? Why didn't you simply
ask "What do you mean by 'perlre'?" You quite likely would have gotten
a helpful pointer to the perl documentation, at which point you could
have read and searched for the phrase "non-capturing". Instead, you
just snipped the portions you didn't understand, and claimed that no
one is being helpful.

Paul Lalli

I never said that no one was being helpful.

But, thanks for your input. I suppose I have learned one lesson: tread
carefully in the comp.lang.perl.misc newsgroup. It's a shame really,
considering the prosthelitizing of perl zealots.
 
P

Paul Lalli

OK, how do I do that ?

It seems to me that *you* can follow this thread just fine, and
appearantly I haven't taken the requisite steps for you do to so,
please explain.

2 different factors:
1) Because I am *choosing* to put more effort than should be required
into following this thread. I am specifically using a newsreader that
automatically threads by default, and have chosen to use that threading
feature, and I am scrolling up to find out who said what when you don't
quote. You should not be assuming that everyone else is doing the
same.
2) Because all of the reply posts HAPPENED to hit the newsserver I'm
using after the messages to which they are replying. NNTP by no means
guarantees this. Posts can arrive in any order, or not at all.
Quoting and providing context allows people to follow a reply message
even if the original message has not yet arrived on their server.
Actually I did do a search in the three perl reference books I have
access to "Learning Perl", "Programming Perl", and "Perl in a
Nutshell"; all O'Reilly books,

What do any of those have to do with this newsgroup? Or with how to
post an effective reply? Or with Usenet custom and tradition?
as well as reviewing several posting in this newsgroup.

And you *never* saw mention of the Posting Guidelines? You are either
astonishingly unobservant, improbably unlucky, or flat out lying.
As I have stated, I missed the sentence which discussed using the
/(?:expression)/ syntax.
I realise now why that is, and it is because /(expression)/ would
appear to have 'used up' the use of parentheses as a grouping operator.
I would never have imagined that they would be reused with the aid of
a ? and :

NO ONE has berated you for not knowing about this feature ahead of
time, or even for not understanding the passage in the relevant
perldoc. What are you talking about?
Hmm...
The first time I have *ever* seen "[no context, no attribution]" used
in a newgroup posting was Anno's response. When I saw it I wasn't even
sure if he had written it, or if it was somehow automatically inserted
by whatever software he was using to post to the newsgroup. Nor did I
understand that it had *any* significance. Since my initial impression
was that it was a software generated sequence of garbage I did the
polite thing and ignored it.

..... you ignored something that at the very least you believed COULD
have been posted by the person attempting to help you, and you consider
that "polite"? I don't even know what to say to that.
I never said that no one was being helpful.
Really?
http://groups.google.com/group/comp.lang.perl.misc/msg/4407297edc15f6db?dmode=source
Your lack of helpfulness, and asinine attitude

To this point, Anno was the only one responding to you. You accused
him of not being helpful. Was there someone else you were claiming was
being helpful?
But, thanks for your input. I suppose I have learned one lesson: tread
carefully in the comp.lang.perl.misc newsgroup.

<sigh> You haven't learned anything, actually. There is no need to
"tread carefully". All that is needed to get the most out of this
group is to put forth some effort into solving your own problems, ask
effective questions, and apply the knowledge gained by the responses.
If the first time you saw "[no context, no attributions]", you had
asked "what are those?", or if the first time you saw "perlre", you
asked "what is that, or where can I find it?", damn near none of this
thread would have happened.

Paul Lalli
 
J

jack

Paul said:
2 different factors:
1) Because I am *choosing* to put more effort than should be required
into following this thread. I am specifically using a newsreader that
automatically threads by default, and have chosen to use that threading
feature, and I am scrolling up to find out who said what when you don't
quote. You should not be assuming that everyone else is doing the
same.

Isn't a threaded newsreader pretty much standard since about 1985 ?
2) Because all of the reply posts HAPPENED to hit the newsserver I'm
using after the messages to which they are replying. NNTP by no means
guarantees this. Posts can arrive in any order, or not at all.
Quoting and providing context allows people to follow a reply message
even if the original message has not yet arrived on their server.


What do any of those have to do with this newsgroup? Or with how to
post an effective reply? Or with Usenet custom and tradition?

Hmm... Isn't this the perl language 'misc' topics newsgroup ?

Which book that I cite falls out of those bounds.
And you *never* saw mention of the Posting Guidelines? You are either
astonishingly unobservant, improbably unlucky, or flat out lying.

I think this is my second posting to any perl related newgroup in the
past 15 years.
I must be improbably unlucky
NO ONE has berated you for not knowing about this feature ahead of
time, or even for not understanding the passage in the relevant
perldoc. What are you talking about?

I never said they did.

Hmm...
The first time I have *ever* seen "[no context, no attribution]" used
in a newgroup posting was Anno's response. When I saw it I wasn't even
sure if he had written it, or if it was somehow automatically inserted
by whatever software he was using to post to the newsgroup. Nor did I
understand that it had *any* significance. Since my initial impression
was that it was a software generated sequence of garbage I did the
polite thing and ignored it.

.... you ignored something that at the very least you believed COULD
have been posted by the person attempting to help you, and you consider
that "polite"? I don't even know what to say to that.

Yes, and No.

Yes, I ignored it, I've already admitted to that.
No, I never believed it COULD have been posted in an attempt to help
me, since it didn't seem to have any contextual relevance. As I have
stated, it looked to me like some gibberish prepended to his comments
by some lame software.

Yes, after I was insulted.
To this point, Anno was the only one responding to you. You accused
him of not being helpful. Was there someone else you were claiming was
being helpful?
But, thanks for your input. I suppose I have learned one lesson: tread
carefully in the comp.lang.perl.misc newsgroup.

<sigh> You haven't learned anything, actually. There is no need to
"tread carefully". All that is needed to get the most out of this
group is to put forth some effort into solving your own problems, ask
effective questions, and apply the knowledge gained by the responses.
If the first time you saw "[no context, no attributions]", you had
asked "what are those?", or if the first time you saw "perlre", you
asked "what is that, or where can I find it?", damn near none of this
thread would have happened.

Paul Lalli

My point exactly.
 
P

Paul Lalli

I'm replying one last time, because you asked specific questions.
After that, go ahead and have the last word. I'm done with this
thread.

Isn't a threaded newsreader pretty much standard since about 1985 ?
No.


Hmm... Isn't this the perl language 'misc' topics newsgroup ?

Which book that I cite falls out of those bounds.

Not a one. But you posted them in response to my comment about how you
failed to observe *Usenet* traditions, which has absolutely nothing to
do with *Perl*.
I think this is my second posting to any perl related newgroup in the
past 15 years.
I must be improbably unlucky

Wait, what are you arguing now? You said, in response to my accusation
that you failed to follow Usenet traditions, that you "review[ed]
several posting (sic) in this newsgroup". But now you're saying this
was the second thread to which you ever posted. I'm confused as to
what this new bit of information has to do with my original accusation.
I never said they did.

Perhaps I misunderstood your intention in posting this paragraph, then.
Perhaps you could explain what it was? If it was not in reference to
the passages that came before it, what was the point of it?
Hmm...
The first time I have *ever* seen "[no context, no attribution]" used
in a newgroup posting was Anno's response. When I saw it I wasn't even
sure if he had written it, or if it was somehow automatically inserted
by whatever software he was using to post to the newsgroup. Nor did I
understand that it had *any* significance. Since my initial impression
was that it was a software generated sequence of garbage I did the
polite thing and ignored it.

.... you ignored something that at the very least you believed COULD
have been posted by the person attempting to help you, and you consider
that "polite"? I don't even know what to say to that.

Yes, and No.

Yes, I ignored it, I've already admitted to that.
No, I never believed it COULD have been posted in an attempt to help
me, since it didn't seem to have any contextual relevance.

.... I don't understand how you can say that, while simultaneously
quoting your original passage: "When I saw it, I wasn't even sure if he
had written it". You weren't sure. So you didn't know. So it COULD
have been one way or the other.
As I have
stated, it looked to me like some gibberish prepended to his comments
by some lame software.

Yes, that was the assumption you made... but you also seemed to
acknowledge that it *was* an assumption, and that there were
alternative explanations. Are you now saying this was not the case?
But, thanks for your input. I suppose I have learned one lesson: tread
carefully in the comp.lang.perl.misc newsgroup.

<sigh> You haven't learned anything, actually. There is no need to
"tread carefully". All that is needed to get the most out of this
group is to put forth some effort into solving your own problems, ask
effective questions, and apply the knowledge gained by the responses.
If the first time you saw "[no context, no attributions]", you had
asked "what are those?", or if the first time you saw "perlre", you
asked "what is that, or where can I find it?", damn near none of this
thread would have happened.

My point exactly.

Ah. I see. So the combination of those three factors (put forth
effort, ask effective questions, and and apply knowledge) are too much
to ask of you? They add up to needing to "tread carefully"? I think I
now completely understand your mentality. Thanks for clearing that up.

Good day to you. As I said, I will not be replying to anything else in
this thread.

Paul Lalli
 
A

axel

[no attribution, no context, again]
Well, Thank you, I guess ?!?!?
How strange you should say that, I've already learned to not like you.
Oh, great wise sage of comp.lang.perl.misc please help me to gain the
requisite knowledge
I find this to be a very strange conversation. You claim to have given
me the answer, yet when I review your first two postings neither
contains /(?:expression)/
Your lack of helpfulness, and asinine attitude

Whose lack of helpfulness? How many hard Euros did you put down or
how many beers did you reserve? If both as I suspect come to equal
zero, you got more than you paid for.

Axel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top