Regular expressions: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor tidy)
Line 2,993: Line 2,993:
{{libheader|Wren-pattern}}
{{libheader|Wren-pattern}}
The above module allows us to do simple string pattern matching and replacement in a similar fashion to regular expressions but using a different syntax. SenseTalk's examples have been borrowed for this purpose.
The above module allows us to do simple string pattern matching and replacement in a similar fashion to regular expressions but using a different syntax. SenseTalk's examples have been borrowed for this purpose.
<syntaxhighlight lang="ecmascript">import "/pattern" for Pattern
<syntaxhighlight lang="wren">import "./pattern" for Pattern


var s = "This is a story about R2D2 and C3P0 who are best friends."
var s = "This is a story about R2D2 and C3P0 who are best friends."
Line 3,040: Line 3,040:
{{libheader|Wren-regex}}
{{libheader|Wren-regex}}
The above module uses RE2 regular expression syntax but, since it is a wrapper for Go's 'regexp' package, it can only be used from a special embedded application and not by Wren-cli.
The above module uses RE2 regular expression syntax but, since it is a wrapper for Go's 'regexp' package, it can only be used from a special embedded application and not by Wren-cli.
<syntaxhighlight lang="ecmascript">/* regular_expressions.wren */
<syntaxhighlight lang="wren">/* Regular_expressions_2.wren */
import "./regex" for Regex
import "./regex" for Regex