From ab7b1f60383994b98db68b9cc5393e65ea247a47 Mon Sep 17 00:00:00 2001 From: yanxiaolong Date: Wed, 14 Apr 2021 12:02:31 +0800 Subject: [PATCH] first commit --- EasyQJson.h | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Myre.pro | 36 ++++++++++++++++++++++++++++++++++++ Myre.pro.user | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Myre.pro.user.e6e3513 | 319 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.en.md | 36 ++++++++++++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++++ RegExp.json | 40 ++++++++++++++++++++++++++++++++++++++++ common.h | 18 ++++++++++++++++++ main.cpp | 11 +++++++++++ myre.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ myre.cpp.autosave | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ myre.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ myre.h.autosave | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ myre.ui | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 15 files changed, 1899 insertions(+), 0 deletions(-) create mode 100644 EasyQJson.h create mode 100644 LICENSE create mode 100644 Myre.pro create mode 100644 Myre.pro.user create mode 100644 Myre.pro.user.e6e3513 create mode 100644 README.en.md create mode 100644 README.md create mode 100644 RegExp.json create mode 100644 common.h create mode 100644 main.cpp create mode 100644 myre.cpp create mode 100644 myre.cpp.autosave create mode 100644 myre.h create mode 100644 myre.h.autosave create mode 100644 myre.ui diff --git a/EasyQJson.h b/EasyQJson.h new file mode 100644 index 0000000..27bc0b6 --- /dev/null +++ b/EasyQJson.h @@ -0,0 +1,121 @@ +#ifndef EASYQJSON_H +#define EASYQJSON_H +#include +#include +#include +#include +#include + +namespace DJY{ + class EasyQJson + { + public: + //读取json文件并且返回Json对象 + QJsonObject readJsonFileReturnObject(QString filepath) + { + QJsonObject rootObj = {}; + QFile file(filepath); + if(!file.open(QIODevice::ReadWrite))//打开文件 + { + return rootObj; + } + //throw std::logical_error(); + + QByteArray all = file.readAll(); + file.close(); + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(all,&json_error)); //读取json + rootObj = jsonDoc.object(); + return rootObj; + } + + //读取QJsonObject返回QString + QString readObjectReturnQString(QJsonObject object) + { + QString result = QString(QJsonDocument(object).toJson()); + return result; + } + + + //提供JsonObject和键值,返回Json数组 + QJsonArray readJsonObjectReturnArray(QJsonObject object, QString jsonkey) + { + QJsonValue value = object.value(jsonkey); + QJsonArray array = value.toArray(); + return array; + } + + //判断Json数组有没有对应的键 + bool JsonArrayContain(QJsonArray array, QString jsonObject, QString target) + { + //传入了array ,jsonobject为要找到的json对象键名,target为这个对象的值 + for(int i = 0;i + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Myre.pro b/Myre.pro new file mode 100644 index 0000000..bf5d9fe --- /dev/null +++ b/Myre.pro @@ -0,0 +1,36 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + myre.cpp + +HEADERS += \ + EasyQJson.h \ + common.h \ + myre.h + +FORMS += \ + myre.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +DISTFILES += \ + RegExp.json diff --git a/Myre.pro.user b/Myre.pro.user new file mode 100644 index 0000000..2a2c45b --- /dev/null +++ b/Myre.pro.user @@ -0,0 +1,340 @@ + + + + + + EnvironmentId + {54cdc97b-c652-44e0-9a5c-0bf57b73d600} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.12.9 MinGW 64-bit + Desktop Qt 5.12.9 MinGW 64-bit + qt.qt5.5129.win64_mingw73_kit + 0 + 0 + 0 + + true + 0 + C:\Users\xiesh\Desktop\study\QT\zhengze\build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Debug + C:/Users/xiesh/Desktop/study/QT/zhengze/build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + C:\Users\xiesh\Desktop\study\QT\zhengze\build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Release + C:/Users/xiesh/Desktop/study/QT/zhengze/build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 2 + + + true + 0 + C:\Users\xiesh\Desktop\study\QT\zhengze\build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Profile + C:/Users/xiesh/Desktop/study/QT/zhengze/build-Myre-Desktop_Qt_5_12_9_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/Myre.pro.user.e6e3513 b/Myre.pro.user.e6e3513 new file mode 100644 index 0000000..0443408 --- /dev/null +++ b/Myre.pro.user.e6e3513 @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {e6e3513a-8a4d-42b2-830e-25f027c55e9a} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MinGW 64-bit + Desktop Qt 5.14.2 MinGW 64-bit + qt.qt5.5142.win64_mingw73_kit + 1 + 0 + 0 + + E:/build-Myre-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:/build-Myre-Desktop_Qt_5_14_2_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + E:/build-Myre-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:E:/Myre/Myre.pro + E:/Myre/Myre.pro + + false + + false + true + true + false + false + true + + E:/build-Myre-Desktop_Qt_5_14_2_MinGW_64_bit-Release + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..fe4c473 --- /dev/null +++ b/README.en.md @@ -0,0 +1,36 @@ +# Myre + +#### Description +可视化的正则表达式工具 + +#### Software Architecture +Software architecture description + +#### Installation + +1. xxxx +2. xxxx +3. xxxx + +#### Instructions + +1. xxxx +2. xxxx +3. xxxx + +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +#### Gitee Feature + +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) +4. The most valuable open source project [GVP](https://gitee.com/gvp) +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md new file mode 100644 index 0000000..6493b81 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Myre + +#### 介绍 +可视化的正则表达式工具 + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 码云特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 +5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/RegExp.json b/RegExp.json new file mode 100644 index 0000000..0a9f4a7 --- /dev/null +++ b/RegExp.json @@ -0,0 +1,40 @@ +{ + "Array" : [ + { + "name" : "字符串匹配", + "value" : "\\b填写字符串\\b" + }, + { + "name" : "匹配QQ号", + "value":"[1-9][0-9]{4,}" + }, + { + "name" : "匹配整数", + "value": "^-?[1-9]\\d*$" + }, + { + "name" : "匹配邮箱地址", + "value": "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?" + }, + { + "name" : "匹配国内电话号码", + "value": "\\d{3}-\\d{8}|\\d{4}-\\{7,8}" + }, + { + "name" : "匹配中文字符", + "value": "[\\u4e00-\\u9fa5]" + }, + { + "name" : "m-n位的数字", + "value": "^\\d{m,n}$" + }, + { + "name" : "正数、负数、和小数", + "value": "^(\\-|\\+)?\\d+(\\.\\d+)?$" + }, + { + "name" : "汉字", + "value": "^[\\u4e00-\\u9fa5]{0,}$" + } + ] +} diff --git a/common.h b/common.h new file mode 100644 index 0000000..5352539 --- /dev/null +++ b/common.h @@ -0,0 +1,18 @@ +#ifndef COMMON_H +#define COMMON_H +#include + +#include +#include +#include +#include +#include"EasyQJson.h" +#include +#ifdef QT_NO_DEBUG +const QString myfilename = "./RegExp.json"; +#else +//const QString myfilename = "/Users/hideyoshi/Desktop/codes/Myre/RegExp.json"; +const QString myfilename = "E:\\Myre\\RegExp.json"; + +#endif +#endif // COMMON_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..a683cb6 --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "myre.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Myre w; + w.show(); + return a.exec(); +} diff --git a/myre.cpp b/myre.cpp new file mode 100644 index 0000000..ea736ef --- /dev/null +++ b/myre.cpp @@ -0,0 +1,130 @@ +#include "myre.h" +#include "ui_myre.h" +Myre::Myre(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::Myre) +{ + ui->setupUi(this); + setFixedSize(800,600); + init_myre(); +} + +Myre::~Myre() +{ + delete ui; +} + + + +void Myre::on_pushButton_exit_clicked() +{ + close(); +} + +void Myre::init_myre() +{ + rootObject = myjson.readJsonFileReturnObject(myfilename); + rootArray = myjson.readJsonObjectReturnArray(rootObject,"Array"); + + QStandardItemModel *model = new QStandardItemModel; + for(int i=0;iappendRow(item); + } + ui->listView->setModel(model); + ui->listView->repaint(); + ui->listView->setEditTriggers(nullptr); +} + +void Myre::on_pushButton_excute_clicked() +{ + ui->textEdit_result->clear(); + QString src = ui->textEdit_text->toPlainText(); + QString target = ui->lineEdit->text(); + qDebug()<textEdit_result->setText("未找到匹配"); + ui->textEdit_result->repaint(); + return; + } + ui->textEdit_result->clear(); + ui->textEdit_result->repaint(); + QRegExp rx(target); + Qt::CaseSensitivity cs = Qt::CaseInsensitive; + if (ui->checkBox_sensetivity->isChecked()) + cs = Qt::CaseSensitive; + rx.setCaseSensitivity(cs); + rx.setMinimal(ui->checkBox_min->isChecked()); + QString synax = ui->comboBox_pattern->currentText(); + + if(synax == "Regular expression V1") + { + rx.setPatternSyntax(QRegExp::RegExp); + } + else if(synax == "Regular expression V2") + { + rx.setPatternSyntax(QRegExp::RegExp2); + } + else if(synax == "WildCard") + { + rx.setPatternSyntax(QRegExp::Wildcard); + } + else if(synax == "Fixed string") + { + rx.setPatternSyntax(QRegExp::FixedString); + } + else if(synax == "W3C Xml Schema 1.1") + { + rx.setPatternSyntax(QRegExp::W3CXmlSchema11); + } + if(rx.isValid()==false) + { + ui->textEdit_result->setTextColor(Qt::red); + ui->textEdit_result->setText("不合法的正则表达式"); + ui->textEdit_result->repaint(); + return; + } + + + int count = 0; + int pos = 0; + while ((pos = rx.indexIn(src, pos)) != -1) + { + ++count; + qDebug()<textEdit_result->setText("未找到匹配"); + } + + ui->textEdit_result->repaint(); + + +} + + +void Myre::on_listView_clicked(const QModelIndex &index) +{ + QString text = index.data().toString(); + int row = index.row(); + QString RegVal = RegValue[row]; + ui->lineEdit->setText(RegVal); + ui->lineEdit->repaint(); +} diff --git a/myre.cpp.autosave b/myre.cpp.autosave new file mode 100644 index 0000000..bd14bce --- /dev/null +++ b/myre.cpp.autosave @@ -0,0 +1,135 @@ +#include "myre.h" +#include "ui_myre.h" +Myre::Myre(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::Myre) +{ + ui->setupUi(this); + setFixedSize(800,600); + init_myre(); +} + +Myre::~Myre() +{ + delete ui; +} + + + +void Myre::on_pushButton_exit_clicked() +{ + close(); +} + +void Myre::init_myre() +{ + rootObject = myjson.readJsonFileReturnObject(myfilename); + rootArray = myjson.readJsonObjectReturnArray(rootObject,"Array"); + + QStandardItemModel *model = new QStandardItemModel; + for(int i=0;iappendRow(item); + } + ui->listView->setModel(model); + ui->listView->repaint(); + ui->listView->setEditTriggers(nullptr); +} + +void Myre::on_pushButton_excute_clicked() +{ + ui->textEdit_result->clear(); + QString src = ui->textEdit_text->toPlainText(); + QString target = ui->lineEdit->text(); + qDebug()<textEdit_result->setText("未找到匹配"); + ui->textEdit_result->repaint(); + return; + } + ui->textEdit_result->clear(); + ui->textEdit_result->repaint(); + QRegExp rx(target); + Qt::CaseSensitivity cs = Qt::CaseInsensitive; + if (ui->checkBox_sensetivity->isChecked()) + cs = Qt::CaseSensitive; + rx.setCaseSensitivity(cs); + rx.setMinimal(ui->checkBox_min->isChecked()); + QString synax = ui->comboBox_pattern->currentText(); + + if(synax == "Regular expression V1") + { + rx.setPatternSyntax(QRegExp::RegExp); + } + else if(synax == "Regular expression V2") + { + rx.setPatternSyntax(QRegExp::RegExp2); + } + else if(synax == "WildCard") + { + rx.setPatternSyntax(QRegExp::Wildcard); + } + else if(synax == "Fixed string") + { + rx.setPatternSyntax(QRegExp::FixedString); + } + else if(synax == "W3C Xml Schema 1.1") + { + rx.setPatternSyntax(QRegExp::W3CXmlSchema11); + } + if(rx.isValid()==false) + { + ui->textEdit_result->setTextColor(Qt::red); + ui->textEdit_result->setText("不合法的正则表达式"); + ui->textEdit_result->repaint(); + return; + } + + + int count = 0; + int pos = 0; + while ((pos = rx.indexIn(src, pos)) != -1) + { + ++count; + qDebug()<textEdit_result->setText("未找到匹配"); + } + + ui->textEdit_result->repaint(); + + +} + + +void Myre::on_listView_clicked(const QModelIndex &index) +{ + QString text = index.data().toString(); + int row = index.row(); + QString RegVal = RegValue[row]; + ui->lineEdit->setText(RegVal); + ui->lineEdit->repaint(); +} + +void Myre::on_pushButton_openfile_clicked() +{ + +} diff --git a/myre.h b/myre.h new file mode 100644 index 0000000..6a1226c --- /dev/null +++ b/myre.h @@ -0,0 +1,57 @@ +#ifndef MYRE_H +#define MYRE_H + +#include +#include"common.h" +QT_BEGIN_NAMESPACE +namespace Ui { class Myre; } + +QT_END_NAMESPACE + +using namespace DJY; + +class Myre : public QMainWindow +{ + Q_OBJECT + +public: + Myre(QWidget *parent = nullptr); + ~Myre(); + + QSet getAllMatchResults(const QString text,const QString regexp) + { + QSetresultSet; + QRegExp rx(regexp); + int pos=0; + while((pos=rx.indexIn(text,pos))!=-1) + { + pos += rx.matchedLength(); + QString result=rx.cap(0); + resultSet< +#include"common.h" +QT_BEGIN_NAMESPACE +namespace Ui { class Myre; } + +QT_END_NAMESPACE + +using namespace DJY; + +class Myre : public QMainWindow +{ + Q_OBJECT + +public: + Myre(QWidget *parent = nullptr); + ~Myre(); + + QSet getAllMatchResults(const QString text,const QString regexp) + { + QSetresultSet; + QRegExp rx(regexp); + int pos=0; + while((pos=rx.indexIn(text,pos))!=-1) + { + pos += rx.matchedLength(); + QString result=rx.cap(0); + resultSet< + + Myre + + + + 0 + 0 + 800 + 600 + + + + Myre + + + + + + 670 + 550 + 112 + 32 + + + + 退出 + + + + + + 10 + 0 + 121 + 551 + + + + + + + 140 + 10 + 226 + 34 + + + + + + + 匹配 + + + + + + + 打开文件 + + + + + + + + + 140 + 50 + 641 + 23 + + + + + + + 正则表达式 + + + + + + + + + + + + 140 + 70 + 641 + 481 + + + + + + + 文本 + + + + + + + + 0 + 250 + + + + + + + + 结果 + + + + + + + + + + + + 391 + 10 + 231 + 32 + + + + + + + + 50 + 16777215 + + + + 模式语法 + + + + + + + + Regular expression V1 + + + + + Regular expression V2 + + + + + WildCard + + + + + Fixed String + + + + + W3C Xml Schema 1.1 + + + + + + + + + + 630 + 0 + 138 + 45 + + + + + + + 敏感模式 + + + + + + + 最小匹配 + + + + + + + + + + 0 + 0 + 800 + 22 + + + + + + + -- libgit2 0.21.4