Matching a regular expression within a string
Regular expressions provide us with a powerful method to locate an arbitrarily complex pattern within a string. The regexp
command is similar to a Find function in a text editor. You search for a defined string for the character or the pattern of characters you are looking for and it returns a Boolean value that indicates success or failure and populates a list of optional variables with any matched strings. The -indices
and -inline
options must be used to modify the behavior, as indicated by this statement. But it doesn't stop there; by providing switches, you can control the behavior of regexp
. The switches are as follows:
Switch |
Behavior |
---|---|
|
No actual matching is made. Instead |
|
Allows the use of expanded... |