Regexp greediness.

G

Gunnar Hjalmarsson

robic0 said:
I'm out of work right now and would like a project. I'm open to large scale
work propositions. Now is a good time to catch me, once grabbed by the sharks,
even if its shit pay, I will have to take it... and it will consume my time.

Consume your time? Stop you from polluting this newsgroup? That _is_
tempting.
 
T

Tad McClellan

it_says_BALLS_on_your forehead said:
perl -le 'print $1 if q{"this string "some other""} =~ m/"(.+)"/'

...would have the desired output.


Errr, yes. If you change the problem, the answer is likely to change.
 
T

Tad McClellan

First and formost, alternation (this regex '->|<-' as an example) is character
or group orientated, specifically '>|<'. Anything to the left or right is NOT,
I repeat NOT considered in the alternation character '|' syntax.

Is that not correct, or what ???


That is not correct.

perldoc perlre

You can specify a series of alternatives for a pattern using "|" to
separate them, so that C<fee|fie|foe> will match any of "fee", "fie",
or "foe" in the target string (as would C<f(e|i|o)e>). The
first alternative includes everything from the last pattern delimiter
("(", "[", or the beginning of the pattern) up to the first "|", and
the last alternative contains everything from the last "|" to the next
pattern delimiter.
 
R

robic0

Consume your time? Stop you from polluting this newsgroup? That _is_
tempting.
Yeah, very cool Gunnar......
I'm giving it to you on the alternation stupididy I was claiming.
An observation on the regexp core, an alternation without grouping is cute.
Because they can do it, didn't mean functionality is guaranteed. Its use without
grouping is limitting at most.

I'm new to Perl, but I ain't stupid. I've got 15 million lines of code I've written
over 20 years, to back me up. I get things done in a hurry!

Do I know regex now? Yeah, within the last 2 months, intense usage.
Not that Perl regex is anything great. The MS version manages to do a !
(not) construct on phrases. Its kind of hard coming from assembly/C to imagining
the machinations necessary. If its not a specific assembly core (not C compiled ... api
dependent) a mistake was made. Into that realm, machine cycles rule.
Anybody who's written assembly knows load register pairs and get the content of that
address. And weather a jne is more efficient than a ret. If the prime regex design
is written in C, its flawwed performance wise. When I used to do real-time machine
code, it had to add up, algebric nop's mean ineficiency and conceptual errors.
Imagine an analysis on the regex core's runtime assembly. A couple of tweaks
reaping > %10-30 efficiency. This on the stupidist of things, returns, jumps,
indirection. If the Perl gods pay me, I can get these for them and insure the
longevity of Perl. Which btw is declining. Its not that I know that, its just
I 'feel' it. There is no seeming draw to program in a language that is so easily
plagerized. I've done a few very large programs in Perl now (for employers),
hardly catagorized as scripts. So its got the potential. Just in the last
day or two, I'd read a post by a CPAN contributor notifying a mod to his module
where some asshole responded, "hey dude, can you add this an that function" as if
**** your effort but it aint good enough. And taken for grantit.
That AIN'T THE **** THAT IM INTO. I won't give it away. Sure, I'll make it as I
see a need, but I will design it and do it for myself. The xml processor tools I'm
making right now are for a business I am trying to start, a business that makes me
money for my wife and kids. Seing how its Perl, the supreme OPEN SOURCE, it and its
community can kiss my ass. I can write anything in Perl or the manag'e of other langs.
I don't think open source attitude applies to very useful application machinations
wheather written in Perl or any other ahh language (what ever a language is).

Its not true when you get older (I'm 52), in software, err. logic, you decline.
Since I started 'logic' training at about 23, its deep memory. I never went to
school for programming. Programming is not programming as you percieve it.
Either you were born with logic type of brain or you weren't! Lawyers (some) were.
They have it easy, they don't have to do proofs (just big fuckin words). My mind is
different than most. The logic flashes as a complete proof, one way or the other
mostly in an instant (even if approximate, based on the known state). My exhaserbation
nowadays is that problem(matic) description (information) is meaded out by individuals
who parrot phrasiology that is realistically inteded to be on some obscure advertisement
plane. Its really funny how the technical experts role in technology are assigned
a to yes or no answer. But I'm not in that role anymore. I won't be. I will be doing
things on my terms now and for the nextr 20 years. The utter disdain I feel for
employers requesting/demanding I 'create' technology for them to market, while
being paid a minimum wage whith 'do it or your out of work' mentality!

Here I got a family to support.
Why you **** suckin, mother fuckin, jackoff, sperm suckin, blowyhard mother fucker asshole!
is what I think now. Thats my attitude...........

-robic0-
 
R

robic0

No it doesn't.

And saying it over and over will not make it so.

Yes, you are correct. It matches -> or <-.
I was wrong..

(I have to see how many responses I have to make here)
 
R

robic0

First and formost, alternation (this regex '->|<-' as an example) is character
or group orientated, specifically '>|<'. Anything to the left or right is NOT,
I repeat NOT considered in the alternation character '|' syntax.

Is that not correct, or what ???


That is not correct.

perldoc perlre

You can specify a series of alternatives for a pattern using "|" to
separate them, so that C<fee|fie|foe> will match any of "fee", "fie",
or "foe" in the target string (as would C<f(e|i|o)e>). The
first alternative includes everything from the last pattern delimiter
("(", "[", or the beginning of the pattern) up to the first "|", and
the last alternative contains everything from the last "|" to the next
pattern delimiter.

Yes, you are correct. It matches -> or <-.
I was wrong..

(I've almost coverd this mistake, still checking)
 
R

robic0

You cower like a dog, and make excuses.
Stand the **** up and walk and talk like a man!

My apology adamomitcheney, this statement above
was totally uncalled for period! I am flogging myself
now as I write this.
I will never make a statement like this again. I was totally
out of like and apologize! Please accept my apology for this
utterly rude, inappropriate statement.
Sorry!
-robic0-
 
R

robic0

I'd just like to start with a D'Oh!
Yes... the documentation for what the special characters do in a
regexp... ;-)

No, it was just being daft - I wasn't even looking there (initially
using '[' when I should have been grouping with '()' and I should have
known better.
[ ] make up a character class. They look for any ONE character within
their contained class. You were trying to do an alternation and
cluster the two alternates together. That is accomplished with
parentheses and the |, like so:

(?:->|<-)

The ?: prevents these parentheses from being recognized as a capturing
grouping, thus setting one of the $1, $2, etc variables.

Aye, that was what I was missing.

Thanks for taking the time to point it out.

Adam...
Did you thank me and all the others for the time to point things out?
Nobody here is your boss! We don't control your pay for asskissing.
Just what is it your trying to purchace here?

What?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top