O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The match (string, regex) function

The match function searches for a string/regular expression in the specified string. Here, the string in which the match will search is given as the first argument and the regular expression to be matched is given as the second argument. The match function returns the starting position of the substring (the longest match string) that was matched by the regular expression.

This function also sets the following two AWK variables in the following ways:

  • RSTART: This is set up to contain the starting value returned by the function that is the starting position of the substring. If the pattern does not match, RSTART is set to 0.
  • RLENGTH: This is set up to contain the length of the search string. It is set to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required