/
Stameskaaa
/
Server
Обзор
Документация
Войти
/
Stameskaaa
/
Server
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
node_modules/tokenizer/examples/simple.js
19 строк
661 B
Stameskaaa
first
19 июн 2024, 15:02
19 июн 2024, 15:02
ac1472e
Код
Авторство
О чём код?
var Tokenizer = require('../lib/Tokenizer'); var t = new Tokenizer(function(token, match) { // change the type of the token before emitting it if(match.type == 'word' && token == "coucou") return "coucou"; // this help reduce the number of RegExps needed }); t.addRule(/^"[^"]*"$/, 'citation'); t.addRule(/^"[^"]*$/, 'maybe citation'); // the 'maybe citation' rule is here to continue matching until // the closing quote is found t.addRule(/^salut$/i, 'salut'); t.addRule(/^[',;.:!?-]$/, 'ponctuation'); t.addRule(/^\w+$/, "word"); t.addRule(/^(\s)+$/, 'whitespace'); t.write("coucou Salut\t les \n amis. On m'a dit \"ca va bien?\" "); t.end();