| I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a period to match any one character You would think I would learn it once, and be good. but my #2 problem confounds this: what is a literal character and what is a control character - in the language I am using? for example I might need to escape a period to make it a literal for a regex. If I am checking the files filexc and file.c and want to match the second, the regex I want is ^.*\.c$
in perl, I could say: $rx = "^.*\\.c\$"; ($" is a thing)
if ($f =~ /$regex/) { ...
better would be: if ($f =~ /^.*\.c$/) {...
in python I would write m = re.search("^.*\\.c$",f)
better would be: m = re.search(r'^.*\.c$', f)
in a shell script, I might say: grep "^.*\\.c$"
EDIT: crap, I had to escape my comment because the asterisk in the regex was making my text italic |
It's similar to SQL when you think about it. You set up a query to get the data you need and move on to other things. And every RDBMs implements their own flavor of SQL which can complicate things.