1 Star 0 Fork 0

meiyh/regexpme

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

RegexpMe

中文 | English

一个JavaScript正则表达式可视化工具

线上 : 无

特点:

  • 用纯JavaScript编写的,不需要后端。
  • 您可以通过html iframe元素将图表嵌入到您自己的站点中。
  • 详细的错误消息。在大多数情况下,它可以指出精确的语法错误位置。
  • 不支持八进制,是的,这是一个特点。 ECMAScript严格模式不支持字符串中的八进制转义,但是许多浏览器仍然支持正则表达式中的八进制转义。我让事情变得更加容易。在RegexpMe, 十进制将永远被当作后参考。如果后面的引用是无效的, e.g. /\1//(\1)//(a)\2/,或者在charset中出现了十进制转义(因为在这种情况下它不能被解释为后引用, e.g. /(ab)[\1]/),RegexpMe总是会犯错误。

多语言

中文,English

构造

全局安装requirejs

npm install requirejs -g

API

Parse to AST

var parse = require('regulex').parse;
var re = /var\s+([a-zA-Z_]\w*);/ ;
console.log(parse(re.source));

可视化

var parse = require('regulex').parse;
var visualize = require('regulex').visualize;
var Raphael = require('regulex').Raphael;
var re = /var\s+([a-zA-Z_]\w*);/;
var paper = Raphael('yourSvgContainer',0,0);
try {
  visualize(parse(re.source),getRegexFlags(re),paper);
} catch(e) {
  if (e instanceof parse.RegexSyntaxError) {
    logError(re,e);
  } else throw e;
}

function logError(re,err) {
  var msg=["Error:"+err.message,""];
  if (typeof err.lastIndex==='number') {
    msg.push(re);
    msg.push(new Array(err.lastIndex).join('-')+"^");
  }
  console.log(msg.join("\n"));
}


function getRegexFlags(re) {
  var flags='';
  flags+=re.ignoreCase?'i':'';
  flags+=re.global?'g':'';
  flags+=re.multiline?'m':'';
  return flags;
}

开源许可

License

The MIT License (MIT) Copyright (c) 2018 Jex & hua Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个JavaScript正则表达式解析器和可视化工具。(中英文) 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者 (1)

全部

近期动态

2年多前推送了新的 master 分支
接近7年前推送了新的 master 分支
接近7年前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/meeyh/regexpme.git
git@gitee.com:meeyh/regexpme.git
meeyh
regexpme
regexpme
master

搜索帮助