Jump to content
  • Advertisement
Sign in to follow this  
xyuri

awk regex

This topic is 4553 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 dont know if anyone on these forums will be able to help me with awk, but its worth a shot ... I am just trying to validate an ID number with regex in awk, but even though it works fine with other regex tools it simply wont with awk, which is really starting to cheese me off right now. just a simple function: ##################################################################### function chkForm_Id(s) { #check that id meets standard form return s ~ /^\d*$/; } using it like "chkForm_Id(123)", and it works fine if i take either (or both) the carat and dollar symbols out, but this should work fine. Would anyone like to educate me as to what is messing up here? Any help will be greatly appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by xyuri
function chkForm_Id(s) {
#check that id meets standard form
return s ~ /^\d*$/;
}


Feh. the backslash-d thing is a PERL pattern-matching expression, not a real regex. Stephen Kleene rolls over in his grave every time some one claims their line noise is a program in that "language."

You have to stick to real regular expressions using tools like awk, sed, and grep.

Share this post


Link to post
Share on other sites
Thank you both very much for your responses. I have been doing a fair amount of regex since yesterday and have got more used to this "propper" regex expressions :) Thank you.

Share this post


Link to post
Share on other sites
Another quick one though ... in a range like [1-50] why will [1-99] work but [1-100] wont? I need to check -1 up to 100 but this has got me :(

Share this post


Link to post
Share on other sites
Quote:
Original post by xyuri
Another quick one though ... in a range like [1-50] why will [1-99] work but [1-100] wont? I need to check -1 up to 100 but this has got me :(


nevermind, found my answer. sorry to anyone readin this thread ;)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!