A regular expression or regex selector can be used to extract partial values from an atom or its metadata. When followed by a value, a regex selector can perform a search and replace function on the value returned from the atom or metadata.
(@WALT:fullname /\w+\s/) ⇒ Walter
(@WALT:fullname /\w+\s\w+/ Walt) ⇒ Walt Disney
Since these expressions assume that (@WALT)
has been previously defined, probably in canon, we are only setting the value for this particular instance. The next invocation of the expression without the regex selector would get the canonical value.
(@WALT:fullname) ⇒ Walter Elias Disney
If (@WALT)
were not already canonical, the full expression could be recorded like this:
(@WALT Walt Disney :fullname Walter Elias Disney /\w+\s\w+/ Walt) ⇒ Walt Disney
This is 2-form and contains everything we drew from in forming this value. Note that the selector acts on the value in front of it, so the value of :fullname
in this invocation is Walt Disney.
A regex selector can end with an optional regex-env
or flag, such as /g
which selects a global match. A selector like this followed by a value returns the full original value with the match(es) replaced by the second supplied value.
(@p1 It is not well known that the Disneyland Monorail System and Disneyland Railroad were owned by a separate business, WED Enterprises, which Walt controlled. Later renamed Retlaw Enterprises ("Walter" in reverse), the business was sold by Disney's heirs to the Walt Disney Company in 1982.)
(@p1 /business/g company) ⇒
It is not well known that the Disneyland Monorail System and Disneyland Railroad were owned by a separate company, WED Enterprises, which Walt controlled. Later renamed Retlaw Enterprises ("Walter" in reverse), the company was sold by Disney's heirs to the Walt Disney Company in 1982.