• Advertisement
Sign in to follow this  

awk regex again

This topic is 4304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on an awk script lately, but being a noob at it every now and again I get stuck and dont know why the hell a regex will not work. there is one that worked earlier but now it doesnt ... I am very tired and have spent at least two hours just trying to get this to work :-( This is my end block which is just being used to test this expressing at the moment: END { if (" whatever, 34 " ~ /.*(-1|[0-9]{1,2}|100).*/) { print "ok"; } } why would it not be matching? earlier I was writing much MUCH more complex expressions than that and they worked great first time, but this one is biting me in the ass. any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
There is an interesting tool available called visual-regexp rhat can help you construct and diagnose regular expressions. I know it's available as a debian package, so it must be available elsewhere as well.

Share this post


Link to post
Share on other sites
I already tried it with a tool like this and it works fine! anyone else have some an idea?

Share this post


Link to post
Share on other sites
From the awk manpage:
Quote:

r{n,m}: One or two numbers inside braces denote an interval expression [...] Interval expressions are only available if either --posix or --re-interval is specified on the command line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement