Closed Thread Icon

Preserved Topic: regular expression books Pages that link to <a href="https://ozoneasylum.com/backlink?for=17926" title="Pages that link to Preserved Topic: regular expression books" rel="nofollow" >Preserved Topic: regular expression books\

 
Author Thread
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-09-2001 01:32

Anybody got any good recomendations for books on regular expressions. I know I'm going to need a good grasp of them, and don't like to waste money on trail and error in my book buying.

Aslo, on a side note. Can anybody tell me why I would want to reverse a string, ala strrev() in PHP?

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-09-2001 04:13

while (x > 0)
{
x = x+""x%2"";
x >> 1;
}
x = strrev(x);

This would be a simple binary conversion program that outputs to a string. That is a use of the strrev function, but another way to do this would be to change it to

while (x > 0)
{
x = ""x%2""+x;
x >> 1;
}

There by avoiding the need to reverse it, but who knows there may be reasons. Checking for paladroms, I don't know, it is not the most useful function IMO but it is none the less a function.

-mage-

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 04-09-2001 04:26

_Mastering Regular Expressions_ by Jeffrey Friedl (O'Reilly) seems to be the one everybody refers to. I think it *** as a learning book. Don't buy it.

I'd focus on a resource that has applicability to your preferred language, 'cause there are a few different flavors of regexps.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-09-2001 04:44

Thanks Mage, next time I need to search for bob, I'll know just the function to use.

Thanks for the input on that book linear. I was just searching the book sites, and thats about the only book that comes up in a search for regular expressions. I would have ended up with it, but I'll start searching the web for other sources instead.

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 04-09-2001 04:46

I probably got the most mileage out of looking at other people's code.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-09-2001 04:54

I was looking at what you and WarMage posted in the other thread about this, and it doesn't seem to matter how hard I look at it, it's just jibberish to me. Besides, that's not the kind of code you get to see when you don't work in the business. The only code I see that's not mine, is here at the asylum, or in a book. I don't personally know anybody else who does this stuff. Let the learning search begin.

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 04-09-2001 05:54

Reversing a string is useful if you have to format a number with commas (thousands separators). I don't have the exact regular expression handy, but the dirty secret is:

1) reverse your number
2) insert a comma after every three digits
3) reverse the number again

and you have an algorithm for properly formatting large numbers that a) makes no assumptions about the length of the number and b) requires no if-then-else logic. Very devious. Of course I think there's a PHP builtin function for that, but it's a sweet trick to know in Perl.

I sure understand that it looks like gibberish. I was there too. But if you put in a small amount of effort to understand, you will have access to a power tool. Doing complicated substitutions may be the area where regexps shine most. It's also the easiest to get a leg up on, and one of the most useful. IF you have a web site for a company, and they change their name, you may wind up having to edit a hundred pages, each of which could contain the company name zero or more times. Using that one command in the other thread, you can do it *in one shot.* That ought to make you drool.

My company uses mainframes that produce reports with the ugliest formatting you've ever seen. Of course, web pages have to be beautiful, so regexps to the rescue. They are truly the most powerful tool for turning what you've got into what you want.

If you haven't got a concrete problem to solve of that nature, it is hard to get started. I was in the position of having a bunch of content that needed to be reformatted dynamically because it got updated too frequently to make hand-editing the HTML feasible. When you've really grasped this tool, it's impossible to work without it. I hate having to write C code.

I applaud you for wanting to learn this stuff. It does help enormously to have access to code that uses regular expressions.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-09-2001 21:54

No applause necessary.

Thanks for the pep talk linear, it helps. Your right about things being tough to learn without a real problem at hand to work through. Things stick much better in your mind when you get to learn and apply. Just reading without a concrete reason why I would need or want to use something is a very abstract way to learn for me. I also suck at thinking up practice jobs to try and put something new to use. Just lack of imagination I guess.

Thanks again

« BackwardsOnwards »

Show Forum Drop Down Menu