npm i wasm-re2
import { RE2 } from 'wasm-re2';
const regex = new RE2('(b|^a)', 'g');
const isFound = regex.test('aabc');
// true
const matches = regex.exec('aabc');
// [ ['a', 'a'], ['b', 'b'] ]
Executes a search for a match between a regular expression and a specified string.
Returns true or false.
Returns all matches of the regular expression against a string.
Works like non-iterable RegExp matchAll.
Exec returns all results in a 2D array where each result consists of [fullmatch, ...captureMathces].
Example:
const regex = new RE2('(abc)\\d+(zxc)', 'g');
regex.exec('123abc123zxc123abc123zxc123')
// [ ['abc123zxc', 'abc', 'zxc'], ['abc123zxc', 'abc', 'zxc'] ]
Return a new string with some or all matches of a pattern replaced by a replacement.
Returns number of capture groups.
If you use mac proceed to Pull submodule google-re2. You need node and python to be installed.
Install Debian from Microsoft Store, then launch and create UNIX user.
Enter new UNIX username:
New password:
Retype new password:
Then launch:
sudo apt-get update -y && sudo apt-get install nodejs npm git python -y
Install Subsystem WSL using Setting on Windows 10:
- Open
Settings
. - Click on
Apps
. - Under the
Related settings
section, click thePrograms and Features
option. - Click the
Turn Windows features on or off
option on the left pane. - Check the
Windows Subsystem
for the Linux checkbox. - Click the
OK
button. - Then you need to reboot the PC.
Launch IDE with WSL, and do all next actions in WSL Terminal.
git submodule update --init
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
from emsdk dir:
source ./emsdk_env.sh
from re2:
source ../emsdk/emsdk_env.sh
npm i
npm run foundation
Run script npm run compile
npm test
git pull --recurse-submodules
npm run build:update
To change rollup configuration read Rollup_FAQ.md
in yaml-core
package or visit https://rollupjs.org/guide/en/.