File: example.js

package info (click to toggle)
node-regjsgen 0.5.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 232 kB
  • sloc: makefile: 2; sh: 2
file content (12 lines) | stat: -rw-r--r-- 446 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
// the parser goes from the regex-string to the regex-AST
parse = require('regjsparser').parse
// the generator goes the other way around
gen = require('regjsgen').generate
// we start from a trivial regex-string
orig = 'abc+'
console.log ('Original regex: ' + orig)
// turn the regex-string to regex-AST
ast = parse(orig)
// turn the regex-AST back to regex-string 
final = gen(ast)
console.log('Regex after two inverse transforms : ' + final)