separate str
separate(re, str)
separate(re, n, str)
For an introduction to regular expressions, see regular expressions.
Example 1: The command separate(s) breaks the string at every occurrence of \r\n or \n.
|
|
This is equivalent to using the lines function.
|
Example 2: use commas, periods, and semicolons as separators.
|
Example 3: match any number of consecutive spaces.
|
|
Example 4: delete every word starting with "x" from a string, by using concatenate together with separate.
|
|
Example 5: The optional argument n allows us to specify a separator that differs from the match criteria. In the previous example, words beginning with "x" were both the match and the separator. In this example, we match words beginning with "x", but separate the string using the leading "x". With concatenate, this results in deleting just the "x" from words starting with "x" (not the same as removing every "x").
|
separateRegexp is a deprecated synonym for separate.
For backwards compatibility, if the pattern is a single character and it is an unescaped special character, such as +, *, or ., then it is treated as a literal character. In future code, the pattern must be escaped.
The object separate is a method function with options.