The operator always returns a value, which can always be interpreted as true if the application of the regular expression is successful, false otherwise. Now let's see some examples:
Code:
(A) / 0 /
(B) m / \ s * | \ w + /
(C) s / [\ t \ n] + / / g
(D) tr / az / AZ /
The <prefix> can be m (matching), s (replacement), tr (translation). The bars / are normally used as delimiters and have a function similar to the quotes used to delimit a string. In fact, you can use any character as a delimiter (it is sufficient that the first and last are the same) but if the fence is not necessary to specify the bar <prefix>. If the <delim> <prefix> and the bar is omitted, it is assumed m. The <suffix> used to specify the options side-effect caused by the regular expression, for example, the repetition of a replacement, such as (c). The <regexp> proper use alphanumeric characters in their literal meaning (eg / a / matches "a"), while non-alphanumeric characters generally have a special meaning, and therefore we call them wildcards. The following table summarizes the main wildcards and their meanings.
Code:
CHARACTERS
. any character except newline
[Az] any character listed
(The - results in a sequence, reversing the class ^)
\ S whitespace
\ W a letter or decimal _
\ D to one decimal place
\ S as [^ \ s]
\ W as [^ \ w]
\ D [^ \ d]
ITERATIVE
* 0 or more occurrences
+ 1 or more occurrences
? 0 or 1 occurrences
{N} matches exactly n occurrences
{N,} at least n occurrences
{N, m} occurrences of nam
OTHER
^ Start of string
$ End of string
| Alternative
() Grouping
You can remove the special meaning of a wild card and use it in its literal meaning by preceding it with a backslash, for example / \ * / matches "*". Some alphanumeric characters instead, if they become wildcards are preceded by a backslash and acquire a special meaning that would not normally have, for example / \ d / matches one decimal place.
Bookmarks