March 2018
Beginner to intermediate
416 pages
9h 24m
English
The match function searches for a given string/pattern/regular expression in the input string and returns a positive value when a successful match occurs. It sets the two special variables, RSTART and RLENGTH, that indicate where a regular expression begins and ends:
The contents of the RLENGTH or RSTART variable are set/changed when the match function is invoked.
In the following example, we use the match function to search for a pattern and print all that is present before and after the pattern—as well as the pattern itself, separately—as follows:
$ vi match.awkBEGIN { regex="Singh"; } ...Read now
Unlock full access