LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2016, 10:53 AM   #31
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDo, tinycore, Q4OS,Manjaro
Posts: 4,007

Rep: Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855Reputation: 1855
Red face More bad advice!


I LOVE Regex, but admit it has gotten to be a nasty field overall. I love it because the power is there to match whatever I need to match very nicely in little space. I probably use only 10% of the power that is available, but that 10% is critical. I really hate wobbling back and forth between versions of regex: it can drive you mad!

Solution: run a perl shell, do everything in perl, and use only perl regex. (And NO, I do NOT take that advice myself! Who would do that really?)

;-)
 
Old 04-17-2016, 11:07 AM   #32
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 513

Rep: Reputation: 95
Hi,

I had the grace to had been forced more than 15 years ago to write codes in Perl.
So I read and taught myself Perl, and I learned to like Perl regular expressions.
Then I learned, and somehow, liked the others flavours (shell, file globbing, sed, awk, SQL...).

I do not imagine my IT life without them
 
Old 04-18-2016, 08:05 PM   #33
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,351
Blog Entries: 4

Rep: Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334
Regular expressions are "pretty damned baffling ..." at first.

But then, you begin to realize that you are actually dealing with "the world's tiniest programming language," [1] with a syntax consisting of individual characters.

Each regular-expression string is interpreted by a very "clever, powerful, and fast" piece of software known as "the regular-expression engine." The stated purpose of this engine is "to rip-apart text strings," and I'm sure that you will quickly agree that we computer programmers do this a lot.

Therefore, even though your first few encounters with regular expressions might feel like being slapped in the face with a (hot) cast-iron skillet, it actually is "very worth your time" to persevere.


---
[1] ... excluding APL ...
 
Old 04-18-2016, 11:46 PM   #34
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,354

Rep: Reputation: 1038Reputation: 1038Reputation: 1038Reputation: 1038Reputation: 1038Reputation: 1038Reputation: 1038Reputation: 1038
Quote:
Therefore, even though your first few encounters with regular expressions might feel like being slapped in the face with a (hot) cast-iron skillet, it actually is "very worth your time" to persevere.
ROLF....hilarious and true!
 
Old 04-19-2016, 12:50 AM   #35
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,734
Blog Entries: 20

Rep: Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766Reputation: 3766
How does anybody survive without regex?

I would suggest a change of title for this thread, "How does anybody survive without regex?"

While I find some of the comments entertaining, I found these to be right on target:

Quote:
Originally Posted by syg00 View Post
Couldn't survive without regex - I reckon I use it every day.
Quote:
Originally Posted by brockm789 View Post
I like using regex. They're useful with doing pattern matching/expansion. I use a lot of regex in my shell scripts. I'm not an expert on them, but I know enough to get the results I want.
Quote:
Originally Posted by HMW View Post
By practicing. Not trying to be funny, if you USE regex you will learn. I agree that they are at times a pain in the b.tt, but they are also incredibly useful.
I am certainly not a regex whiz, but I did not find the basics difficult to learn, I use them every day and could not survive without them!

I think the imagined difficulty of learning regexes is fundamentally related to the imagined difficulty of using a shell vs using a GUI. The difficulty is one of actually understanding and resolving some task versus clicking from a limited list of options and hoping one will work.

Expressed a different way, it is the difference between finding some desired needle within a continuum of haystacks, and choosing a pre-packaged needle from a small discrete sub-set of needles.

Granted, there is some variation among syntax, regex, extended regex, perl-compatible regex, but the basics are close enough and the differences memorable enough that they are not problematic for ordinary use. If in doubt I find that I can write a test expression almost as quickly as I can look up an answer - and it sticks with me better!

As quoted above, practice, practice, practice! Don't try to just memorize it, use it! Write expressions and explore the effect! Compare the uses in the environments of use to you - sed, awk, perl, language or application of choice.

And learn that although similar, shell globbing is not regular expressions - a common confusion!

Get over the mental block - Regexes are not really difficult, and can be fun!
 
Old 04-19-2016, 04:50 PM   #36
GaryWeaton
LQ Newbie
 
Registered: Apr 2016
Posts: 7

Rep: Reputation: Disabled
I'm no expert at it too, but regex is important to know and learn especially if you use the terminal more than GUI apps. With regex you can isolate any piece of data from a glob of data to be used for a variable, to piped to another command or whatever the task you need that piece of data for.

You don't need to be am expert at regex. Just know enough to get the job done.

Last edited by GaryWeaton; 04-19-2016 at 04:52 PM.
 
Old 04-19-2016, 07:38 PM   #37
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
for anything more complex than the very basic, don't use sed.

The problem is that "regex" was not standardized for a long time - and different systems implemented it in various ways.

Perl was the first language I know of that made regular expressions actually "regular".
 
Old 10-04-2016, 05:21 PM   #38
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,783

Original Poster
Rep: Reputation: 107Reputation: 107
Another headache

SQL likes %
 
  


Reply

Tags
awk, grep, perl, regex, sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusing issue with Perl regEx - Regex check seems to require variable being set EnderX Programming 1 09-07-2013 04:36 AM
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
Help Linux survive cajunboy2k Linux - News 11 06-05-2006 10:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration