Jump to content

Category:Wren-regex

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Wren-regex is a module which wraps most of Go's 'regexp' package for use by Wren programmers. It consists of two classes: Regex and File. The latter contains some basic text file handling methods which may be useful for this type of application.

It is the thirty-sixth in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.

To use it you need to copy the Wren source code (in the talk page) to a text file called regex.wren and place this in the same directory as the importing script so the Wren-regex executable can find it.

Currently, Wren-cli does not support plug-ins though this or similar functionality is likely to be added in a future version (it's already present in DOME). Consequently, scripts using the Wren-regex module must be run under the control of a special executable whose source code (wren-regex.go) is also included in the talk page. This executable uses WrenGo to translate Wren method calls to calls to the corresponding Go 'regexp' functions and can be built with a command line such as the following using Go 1.18 or later:

   $ go build wren-regex.go

If you're using an earlier version of Go than 1.18, then if you uncomment the 14th line in the file it may still work. However, you must have the latest version of WrenGo.

If you then want to run a script called myscript.wren you would type at the command-line:

   $ ./wren-regex myscript.wren

myscript.wren should include a line such as the following to import the classes you want to use in that particular script:

   import "./regex" for Regex, File

The same executable can be used to run any other Wren-regex scripts unless they require additional functionality not available in Wren itself in which case the Go code will need to be suitably modified and rebuilt.

Go and its standard packages are subject to this license.

Pages in category "Wren-regex"

The following 2 pages are in this category, out of 2 total.