Did you know ... | Search Documentation: |
Predicate re_replace/4 |
Throws an error if With uses a name that doesn't exist in the Pattern.
Pattern | is the pattern text, optionally
followed by /Flags. Flags may include g , replacing all
occurences of Pattern. In addition, similar to re_matchsub/4,
the final output type can be controlled by a flag a (atom)
or s (string, default). The output type can also be
specified by the capture_type option. Capture type suffixes
can modify behavior; for example, the following will change an ISO 8601
format date (YYYY-MM-DD) to American style (m/d/y), and also remove
leading zeros by using the
_I suffix:
re_replace("(?<date> (?<year_I>(?:\\d\\d)?\\d\\d) - (?<month_I>\\d\\d) - (?<day_I>\\d\\d) )"/x, "$month-$day-$year", ISODate, AmericanDate)`
|
With | is the replacement text. It may
reference captured substrings using \ N or $Name. Both N and
Name may be written as {N} and {Name} to avoid ambiguities. If a
substring is named, it cannot be referenced by its number. The single
chracters $ and \ can be escaped by doubling
(e.g., re_replace(".","$$","abc",Replaced) results in Replaced="$bc" ).
(Because \ is an escape character inside strings, you need
to write "\ \ \\ " to get a single
backslash.) |
Options | See re_match/3
for the set of options.
The options that are derived from flags take precedence over the
options in the Options list. In the case of conflicting
flags, the first one is used (e.g., |