ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

Regular Expressions (Regex) - Your Thoughts?

(1/3) > >>

Renegade:
Perhaps freakishly, I love regular expressions. I use them all the time. They literally give me godlike power over text. I find it hard to believe that there are developers out there that don't know what they are, much less that there are developers that can't use them.

They are so useful for more than development though. Anyone that needs to deal with large amounts of text could benefit so much from them. I've helped myself and other people to do hours, days, weeks, months, years, decades, centuries, and even millenia worth of work through regular expressions. (Imagine a human can process/organize 1 line of text in 10 seconds, and then imagine 100 GB of data. 1 line is about 80 characters and you get a bit over 2,000 years worth of work.)

Now, I'm sure a lot of people here have never heard of them, and some use them daily. I'm sure that some people would never have a use, while others that have never heard of them could easily find numerous uses for them to help save time.

My wife doesn't know regular expressions, but I recently helped her out with some work where I used them. It all took me a couple hours, but would have taken her days or more to do.

The uses for Excel jockeys are endless.

Anyways, just looking to see what people think about them.

Now, depending on a few factors...

^(good)?bye$

40hz:
Where would a NIXer be without grep :-*

And if you love regex, you might also like the Awk Programming Language. If you regularly need to manipulate large amounts of text data, Awk is a great way to do it.

 8)

Renegade:
Where would a NIXer be without grep :-*

And if you love regex, you might also like the Awk Programming Language. If you regularly need to manipulate large amounts of text data, Awk is a great way to do it.

 8)
-40hz (November 28, 2010, 01:14 AM)
--- End quote ---

Interesting. I've never really considered AWK anything more than some "obscure" system administrator language for UNIX. I should have a look at it as it sounds like it's right up my alley.

f0dder:
I use regex occasionally, and they've saved me a fair amount of time (even though I need a reference when doing some of the more funky stuff). Pretty useful for massaging text beyond what normal search/replace can do, and invaluable when doing some quick webscraping hackjob (if you've found a security flaw in a social networking site you don't want to spend hours coding a proper solution, but you do want people's private image galleries - or so I've heard).

But I also believe that regexes are over-used. It's way too easy cooking up something that's write-once-never-understand-again, it's utterly unusable for production-quality parsing of external data sources you don't have control over, and for really big input data with complicated regexes you're probably a lot better off writing some high-speed code.

If you're ever using regular expressions for user-supplied data, you should probably take a look at SDL Regex Fuzzer :)

rjbull:
And if you love regex, you might also like the Awk Programming Language. If you regularly need to manipulate large amounts of text data, Awk is a great way to do it.
-40hz (November 28, 2010, 01:14 AM)
--- End quote ---

Back in 1988/1989 the first program I started to learn was the shareware word processor/editor PC-Write.  It was a great program, but only had simple repeat-key macros, i.e., nothing like flow control.  When I began to feel a need for automated editing, the first thing I tried was the stream editor SED.  I couldn't work out how to do something in it, popped up a question on a bulletin board, and someone kindly said, "I don't think SED can do that - try AWK."  So I did.  It became the only programming language I have a passing familiarity with and did huge amounts of work for me (mostly back when I had a job).  A lot of data I handled was fairly ordered, like patent abstracts and files of formulations, and AWK was invaluable for manipulating it.  The book The Awk Programming Language by its original three authors, Aho, Kernighan and Weinberger, is not only good on AWK itself, but a very good tutorial on regular expressions.

You can find out more, and download AWK executables, at either of Prof. Brian Kernighan's home pages:


* Brian Kernighan at Princeton
* Brian Kernighan at Bell Labs
The most popular version of AWK is probably Gnu AWK, Gawk.  Another remarkable extended version, TAWK by Thompson Automation Software, includes a compiler.  Other versions abound, many listed on the AWK FAQ page.

Navigation

[0] Message Index

[#] Next page

Go to full version