mirror of
https://github.com/pdemian/human2regex.git
synced 2025-05-16 04:20:35 -07:00
Initial ssg change
This commit is contained in:
parent
5767619463
commit
fb436be143
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang="en" dir="ltr"><head><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content="Not Found"><meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Error 404 - Not Found</title><link href="bundle.min.css" rel="stylesheet" type="text/css"><meta name="theme-color" content="#212529"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="default"><link rel="icon" type="image/x-icon" href="favicon.ico"></head><body><a class="skip skip-top" href="#maincontent">Skip to main content</a><div class="wrapper"><nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"><div class="container"><a class="navbar-brand" href="index.html"><img src="favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex</a><div class="float-right heading-links"><a class="heading-link" href="index.html">Index</a> <span> | </span> <a class="heading-link" href="tutorial.html">Tutorial</a></div></div></nav><div class="container contained-container" id="maincontent" role="main"><div class="align_header"><div class="mx-auto"><div class="site-heading"><h1>404</h1><span class="subheading">Not Found</span></div></div></div><br><br><br><div class="row"><div class="col-12 mx-auto"><h3 class="align_header">The resource could not be found.</h3></div></div></div><footer><div class="container"><div class="row"><div class="col-lg-8 col-md-10 mx-auto"><p class="copyright">Copyright © 2020 Patrick Demian. This page's source code is available at <a rel="noopener noreferrer" href="https://github.com/pdemian/human2regex">github.com/pdemian/human2regex</a></p></div></div></div></footer></div><script defer="defer" src="bundle.min.js"></script></body></html>
|
<!DOCTYPE html><html lang="en" dir="ltr"><head><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content="Not Found"><meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Error 404 - Not Found</title><link href="/bundle.min.css" rel="stylesheet" type="text/css"><meta name="theme-color" content="#212529"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="default"><link rel="icon" type="image/x-icon" href="/favicon.ico"></head><body><a class="skip skip-top" href="#maincontent">Skip to main content</a><div class="wrapper"><nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"><div class="container"><a class="navbar-brand" href="/index.html"><img src="/favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex</a><div class="float-right heading-links"><a class="heading-link" href="/index.html">Index</a> <span> | </span> <a class="heading-link" href="/tutorial.html">Tutorial</a></div></div></nav><div class="container contained-container" id="maincontent" role="main"><div class="align_header"><div class="mx-auto"><div class="site-heading"><h1>404</h1><span class="subheading">Not Found</span></div></div></div><br><br><br><div class="row"><div class="col-12 mx-auto"><h3 class="align_header">The resource could not be found.</h3></div></div></div><footer><div class="container"><div class="row"><div class="col-lg-8 col-md-10 mx-auto"><p class="copyright">Copyright © 2021 Patrick Demian. This page's source code is available at <a rel="noopener noreferrer" href="https://github.com/pdemian/human2regex">github.com/pdemian/human2regex</a></p></div></div></div></footer></div><script defer="defer" src="/bundle.min.js"></script></body></html>
|
2
docs/bundle.min.css
vendored
2
docs/bundle.min.css
vendored
File diff suppressed because one or more lines are too long
14
docs/bundle.min.js
vendored
14
docs/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +1,4 @@
|
|||||||
<!DOCTYPE html><html lang="en" dir="ltr"><head><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content="Create regular expressions with natural, human language"><meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Human2Regex</title><link href="bundle.min.css" rel="stylesheet" type="text/css"><meta name="theme-color" content="#212529"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="default"><link rel="icon" type="image/x-icon" href="favicon.ico"></head><body><a class="skip skip-top" href="#maincontent">Skip to main content</a><div class="wrapper"><nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"><div class="container"><a class="navbar-brand" href="index.html"><img src="favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex</a><div class="float-right heading-links"><a class="heading-link" href="index.html">Index</a> <span> | </span> <a class="heading-link" href="tutorial.html">Tutorial</a></div></div></nav><div class="container" id="maincontent" role="main"><div class="row"><div class="col-lg-8 tenpx-margin-bottom"><div class="form-group row zero-margin-bottom"><label for="dialect" class="col-sm-4 col-form-label">Regex dialect:</label><div class="col-sm-8"><select class="form-control" id="dialect"><option value="js" selected="selected">Javascript</option><option value="dotnet">.NET</option><option value="python">Python</option><option value="boost">C++ Boost</option><option value="java">Java 7+</option><option value="pcre">PCRE</option></select></div></div><h4>Your Regular Expression:</h4><div class="row"><div class="col-xl-11 tenpx-margin-bottom"><input readonly="readonly" class="form-control" id="regex"></div><div class="col-xl-1"><button type="button" class="btn btn-secondary float-right" id="clip">Copy</button></div></div><h4>Human Speak:</h4><textarea class="form-control" id="human" rows="25">
|
<!DOCTYPE html><html lang="en" dir="ltr"><head><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content="Create regular expressions with natural, human language"><meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Human2Regex</title><link href="/bundle.min.css" rel="stylesheet" type="text/css"><meta name="theme-color" content="#212529"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="default"><link rel="icon" type="image/x-icon" href="/favicon.ico"></head><body><a class="skip skip-top" href="#maincontent">Skip to main content</a><div class="wrapper"><nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"><div class="container"><a class="navbar-brand" href="/index.html"><img src="/favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex</a><div class="float-right heading-links"><a class="heading-link" href="/index.html">Index</a> <span> | </span> <a class="heading-link" href="/tutorial.html">Tutorial</a></div></div></nav><div class="container" id="maincontent" role="main"><div class="row"><div class="col-lg-8 tenpx-margin-bottom"><div class="form-group row zero-margin-bottom"><label for="dialect" class="col-sm-4 col-form-label">Regex dialect:</label><div class="col-sm-8"><select class="form-control" id="dialect"><option value="js" selected="selected">Javascript</option><option value="dotnet">.NET</option><option value="python">Python</option><option value="boost">C++ Boost</option><option value="java">Java 7+</option><option value="pcre">PCRE</option></select></div></div><h4>Your Regular Expression:</h4><div class="row"><div class="col-xl-11 tenpx-margin-bottom"><input readonly="readonly" class="form-control" id="regex"></div><div class="col-xl-1"><button type="button" class="btn btn-secondary float-right" id="clip">Copy</button></div></div><h4>Human Speak:</h4><textarea class="form-control" id="human" rows="25">/* Make a regex that matches (basic) URLs */
|
||||||
/* Make a regex that matches (basic) URLs */
|
|
||||||
|
|
||||||
using global and exact matching
|
using global and exact matching
|
||||||
create an optional group called protocol
|
create an optional group called protocol
|
||||||
@ -30,5 +29,4 @@ create an optional group
|
|||||||
create an optional group
|
create an optional group
|
||||||
# fragment, again, we don't care, so ignore everything afterwards
|
# fragment, again, we don't care, so ignore everything afterwards
|
||||||
match "#"
|
match "#"
|
||||||
match 0+ any thing
|
match 0+ any thing</textarea><h4>Errors:</h4><textarea readonly="readonly" class="form-control" id="errors" rows="5"></textarea></div><br><div class="col-lg-4 tenpx-margin-bottom"><div class="cheatsheet"><h2>Cheat Sheet:</h2><p>Full documentation available <a href="/tutorial.html">here</a></p><p class="font-weight-bold">Matching</p><p><code class="cm-s-idea">match "hello world"</code> matches "hello world" exactly</p><p></p><p><code class="cm-s-idea">match "hello" then optionally " world"</code> matches "hello" or "hello world"</p><p><code class="cm-s-idea">match "hello" or "world"</code> matches "hello" or "world</p><p><code class="cm-s-idea">match a word</code> matches any word</p><p class="font-weight-bold">Repetition</p><p><code class="cm-s-idea">match 0+ "hello"</code> matches 0 or more "hello"s</p><p><code class="cm-s-idea">match 3 "hello"</code> matches exactly "hellohellohello"</p><p><code class="cm-s-idea">match 1 to 5 "hello"</code> matches between 1 to 5 "hello"s</p><p><code class="cm-s-idea">repeat 0 or more</code> repeats the intended text 0 or more times (default)</p><p><code class="cm-s-idea">optionally repeat between 3 to 5</code> optionally repeats the indented text 3 to 5 times</p><p class="font-weight-bold">Grouping</p><p><code class="cm-s-idea">create a group called mygroup</code> creates a group called "mygroup"</p><p><code class="cm-s-idea">create an optional group</code> creates an unnamed optional group</p><p class="font-weight-bold">Using</p><p><code class="cm-s-idea">using global and case insensitive</code> uses the 'g' and 'i' flags</p><p class="font-weight-bold">Misc</p><p><code class="cm-s-idea">// comment</code> is a single line comment</p><p><code class="cm-s-idea">/* comment */</code> is a multi line comment</p></div></div></div></div><footer><div class="container"><div class="row"><div class="col-lg-8 col-md-10 mx-auto"><p class="copyright">Copyright © 2021 Patrick Demian. This page's source code is available at <a rel="noopener noreferrer" href="https://github.com/pdemian/human2regex">github.com/pdemian/human2regex</a></p></div></div></div></footer></div><script defer="defer" src="/bundle.min.js"></script></body></html>
|
||||||
</textarea><h4>Errors:</h4><textarea readonly="readonly" class="form-control" id="errors" rows="5"></textarea></div><br><div class="col-lg-4 tenpx-margin-bottom"><div class="cheatsheet"><h2>Cheat Sheet:</h2><p>Full documentation available <a href="tutorial.html">here</a></p><p class="font-weight-bold">Matching</p><p><code class="cm-s-idea">match "hello world"</code> matches "hello world" exactly</p><p></p><p><code class="cm-s-idea">match "hello" then optionally " world"</code> matches "hello" or "hello world"</p><p><code class="cm-s-idea">match "hello" or "world"</code> matches "hello" or "world</p><p><code class="cm-s-idea">match a word</code> matches any word</p><p class="font-weight-bold">Repetition</p><p><code class="cm-s-idea">match 0+ "hello"</code> matches 0 or more "hello"s</p><p><code class="cm-s-idea">match 3 "hello"</code> matches exactly "hellohellohello"</p><p><code class="cm-s-idea">match 1 to 5 "hello"</code> matches between 1 to 5 "hello"s</p><p><code class="cm-s-idea">repeat 0 or more</code> repeats the intended text 0 or more times (default)</p><p><code class="cm-s-idea">optionally repeat between 3 to 5</code> optionally repeats the indented text 3 to 5 times</p><p class="font-weight-bold">Grouping</p><p><code class="cm-s-idea">create a group called mygroup</code> creates a group called "mygroup"</p><p><code class="cm-s-idea">create an optional group</code> creates an unnamed optional group</p><p class="font-weight-bold">Using</p><p><code class="cm-s-idea">using global and case insensitive</code> uses the 'g' and 'i' flags</p><p class="font-weight-bold">Misc</p><p><code class="cm-s-idea">// comment</code> is a single line comment</p><p><code class="cm-s-idea">/* comment */</code> is a multi line comment</p></div></div></div></div><footer><div class="container"><div class="row"><div class="col-lg-8 col-md-10 mx-auto"><p class="copyright">Copyright © 2020 Patrick Demian. This page's source code is available at <a rel="noopener noreferrer" href="https://github.com/pdemian/human2regex">github.com/pdemian/human2regex</a></p></div></div></div></footer></div><script defer="defer" src="bundle.min.js"></script></body></html>
|
|
File diff suppressed because one or more lines are too long
2
lib/generator.d.ts
vendored
2
lib/generator.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
import { IToken } from "chevrotain";
|
import { IToken } from "chevrotain";
|
||||||
/**
|
/**
|
||||||
* List of regular expression dialects we support
|
* List of regular expression dialects we support
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.RegularExpressionCST = exports.IfIdentStatementCST = exports.IfPatternStatementCST = exports.BackrefStatementCST = exports.GroupStatementCST = exports.RepeatStatementCST = exports.MatchStatementCST = exports.CountSubStatementCST = exports.UsingStatementCST = exports.MatchSubStatementCST = exports.StatementCST = exports.MatchStatementValue = exports.MatchSubStatementValue = exports.MatchSubStatementType = exports.UsingFlags = exports.H2RCST = exports.GeneratorContext = exports.RegexDialect = void 0;
|
exports.RegularExpressionCST = exports.IfIdentStatementCST = exports.IfPatternStatementCST = exports.BackrefStatementCST = exports.GroupStatementCST = exports.RepeatStatementCST = exports.MatchStatementCST = exports.CountSubStatementCST = exports.UsingStatementCST = exports.MatchSubStatementCST = exports.StatementCST = exports.MatchStatementValue = exports.MatchSubStatementValue = exports.MatchSubStatementType = exports.UsingFlags = exports.H2RCST = exports.GeneratorContext = exports.RegexDialect = void 0;
|
||||||
/**
|
/**
|
||||||
|
2
lib/generator_helper.d.ts
vendored
2
lib/generator_helper.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/**
|
/**
|
||||||
* Minimizes the match string by finding duplicates or substrings in the array
|
* Minimizes the match string by finding duplicates or substrings in the array
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.dontClobberRepetition = exports.groupIfRequired = exports.minimizeMatchString = void 0;
|
exports.dontClobberRepetition = exports.groupIfRequired = exports.minimizeMatchString = void 0;
|
||||||
/**
|
/**
|
||||||
|
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/**
|
/**
|
||||||
* Includes all packages
|
* Includes all packages
|
||||||
* @packageDocumentation
|
* @packageDocumentation
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.RegexDialect = exports.ParseResult = exports.Human2RegexParser = exports.Human2RegexParserOptions = exports.TokenizeResult = exports.IndentType = exports.Human2RegexLexer = exports.Human2RegexLexerOptions = exports.CommonError = void 0;
|
exports.RegexDialect = exports.ParseResult = exports.Human2RegexParser = exports.Human2RegexParserOptions = exports.TokenizeResult = exports.IndentType = exports.Human2RegexLexer = exports.Human2RegexLexerOptions = exports.CommonError = void 0;
|
||||||
/**
|
/**
|
||||||
|
2
lib/lexer.d.ts
vendored
2
lib/lexer.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/**
|
/**
|
||||||
* The Lexer for Human2Regex
|
* The Lexer for Human2Regex
|
||||||
* @packageDocumentation
|
* @packageDocumentation
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.Human2RegexLexer = exports.TokenizeResult = exports.Human2RegexLexerOptions = exports.IndentType = void 0;
|
exports.Human2RegexLexer = exports.TokenizeResult = exports.Human2RegexLexerOptions = exports.IndentType = void 0;
|
||||||
/**
|
/**
|
||||||
|
2
lib/parser.d.ts
vendored
2
lib/parser.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/**
|
/**
|
||||||
* The parser for Human2Regex
|
* The parser for Human2Regex
|
||||||
* @packageDocumentation
|
* @packageDocumentation
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
2
lib/tokens.d.ts
vendored
2
lib/tokens.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/** @internal */ export declare const Zero: import("chevrotain").TokenType;
|
/** @internal */ export declare const Zero: import("chevrotain").TokenType;
|
||||||
/** @internal */ export declare const One: import("chevrotain").TokenType;
|
/** @internal */ export declare const One: import("chevrotain").TokenType;
|
||||||
/** @internal */ export declare const Two: import("chevrotain").TokenType;
|
/** @internal */ export declare const Two: import("chevrotain").TokenType;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.CaseInsensitive = exports.CarriageReturn = exports.Newline = exports.Repeat = exports.Called = exports.Create = exports.To = exports.From = exports.Exclusive = exports.Inclusive = exports.Exactly = exports.Times = exports.A = exports.Group = exports.Linefeed = exports.Tab = exports.Between = exports.Not = exports.Matching = exports.Exact = exports.Multiline = exports.Global = exports.Using = exports.Unicode = exports.Number = exports.Boundary = exports.Whitespace = exports.Integer = exports.Decimal = exports.Letter = exports.Character = exports.Digit = exports.Word = exports.And = exports.Or = exports.Anything = exports.Then = exports.Match = exports.Optional = exports.Ten = exports.Nine = exports.Eight = exports.Seven = exports.Six = exports.Five = exports.Four = exports.Three = exports.Two = exports.One = exports.Zero = void 0;
|
exports.CaseInsensitive = exports.CarriageReturn = exports.Newline = exports.Repeat = exports.Called = exports.Create = exports.To = exports.From = exports.Exclusive = exports.Inclusive = exports.Exactly = exports.Times = exports.A = exports.Group = exports.Linefeed = exports.Tab = exports.Between = exports.Not = exports.Matching = exports.Exact = exports.Multiline = exports.Global = exports.Using = exports.Unicode = exports.Number = exports.Boundary = exports.Whitespace = exports.Integer = exports.Decimal = exports.Letter = exports.Character = exports.Digit = exports.Word = exports.And = exports.Or = exports.Anything = exports.Then = exports.Match = exports.Optional = exports.Ten = exports.Nine = exports.Eight = exports.Seven = exports.Six = exports.Five = exports.Four = exports.Three = exports.Two = exports.One = exports.Zero = void 0;
|
||||||
exports.AllTokens = exports.Outdent = exports.Indent = exports.StringLiteral = exports.NumberLiteral = exports.Identifier = exports.MultilineComment = exports.SingleLineComment = exports.WS = exports.EndOfLine = exports.Else = exports.If = exports.The = exports.Call = exports.OrMore = exports.CaseSensitive = void 0;
|
exports.AllTokens = exports.Outdent = exports.Indent = exports.StringLiteral = exports.NumberLiteral = exports.Identifier = exports.MultilineComment = exports.SingleLineComment = exports.WS = exports.EndOfLine = exports.Else = exports.If = exports.The = exports.Call = exports.OrMore = exports.CaseSensitive = void 0;
|
||||||
|
2
lib/utilities.d.ts
vendored
2
lib/utilities.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
/**
|
/**
|
||||||
* Some utility functions for Human2Regex
|
* Some utility functions for Human2Regex
|
||||||
* @packageDocumentation
|
* @packageDocumentation
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */
|
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.CommonError = exports.append = exports.regexEscape = exports.removeQuotes = exports.findLastIndex = exports.last = exports.first = exports.isSingleRegexCharacter = exports.combineFlags = exports.hasFlag = exports.makeFlag = exports.usefulConditional = exports.unusedParameter = void 0;
|
exports.CommonError = exports.append = exports.regexEscape = exports.removeQuotes = exports.findLastIndex = exports.last = exports.first = exports.isSingleRegexCharacter = exports.combineFlags = exports.hasFlag = exports.makeFlag = exports.usefulConditional = exports.unusedParameter = void 0;
|
||||||
/**
|
/**
|
||||||
|
4443
package-lock.json
generated
4443
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,6 @@
|
|||||||
"@types/glob": "^7.1.3",
|
"@types/glob": "^7.1.3",
|
||||||
"@types/html-minifier": "^3.5.3",
|
"@types/html-minifier": "^3.5.3",
|
||||||
"@types/jest": "^26.0.19",
|
"@types/jest": "^26.0.19",
|
||||||
"@types/mustache": "^4.1.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.11.1",
|
"@typescript-eslint/eslint-plugin": "^4.11.1",
|
||||||
"@typescript-eslint/parser": "^4.11.1",
|
"@typescript-eslint/parser": "^4.11.1",
|
||||||
"before-build-webpack": "^0.2.9",
|
"before-build-webpack": "^0.2.9",
|
||||||
@ -17,10 +16,10 @@
|
|||||||
"css-loader": "^4.3.0",
|
"css-loader": "^4.3.0",
|
||||||
"eslint": "^7.17.0",
|
"eslint": "^7.17.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
|
"handlebars": "^4.7.6",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"mini-css-extract-plugin": "^1.3.3",
|
"mini-css-extract-plugin": "^1.3.3",
|
||||||
"mustache": "^4.1.0",
|
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.4",
|
"optimize-css-assets-webpack-plugin": "^5.0.4",
|
||||||
"remove-files-webpack-plugin": "^1.4.4",
|
"remove-files-webpack-plugin": "^1.4.4",
|
||||||
"ts-jest": "^26.4.4",
|
"ts-jest": "^26.4.4",
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
||||||
|
|
||||||
{{> header}}
|
{{> header title="Error 404 - Not Found" description="Not Found"}}
|
||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<div class="container contained-container" id="maincontent" role="main">
|
<div class="container contained-container" id="maincontent" role="main">
|
||||||
<!-- Page Header -->
|
<!-- Page Header -->
|
||||||
<div class="align_header">
|
<div class="align_header">
|
||||||
<div class="mx-auto">
|
<div class="mx-auto">
|
||||||
<div class="site-heading">
|
<div class="site-heading">
|
||||||
<h1>{{error-code}}</h1>
|
<h1>404</h1>
|
||||||
<span class="subheading">{{error-subheading}}</span>
|
<span class="subheading">Not Found</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 mx-auto">
|
<div class="col-12 mx-auto">
|
||||||
<h3 class="align_header">{{{error-string}}}</h3>
|
<h3 class="align_header">The resource could not be found.</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"title": "Error 404 - Not Found",
|
|
||||||
"description": "Not Found"
|
|
||||||
},
|
|
||||||
"error-code": "404",
|
|
||||||
"error-subheading": "Not Found",
|
|
||||||
"error-string": "The resource could not be found."
|
|
||||||
}
|
|
32
src/docs/example_code.hbs
Normal file
32
src/docs/example_code.hbs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* Make a regex that matches (basic) URLs */
|
||||||
|
|
||||||
|
using global and exact matching
|
||||||
|
create an optional group called protocol
|
||||||
|
match "http"
|
||||||
|
possibly match "s"
|
||||||
|
match "://"
|
||||||
|
create an optional group called subdomain
|
||||||
|
repeat
|
||||||
|
match a word, then "."
|
||||||
|
create a group called domain
|
||||||
|
match 1+ words or "_" or "-"
|
||||||
|
match "."
|
||||||
|
match a word
|
||||||
|
# port, but we don't care about it, so ignore it
|
||||||
|
optionally match ":" then 0+ digits
|
||||||
|
create an optional group called path
|
||||||
|
repeat
|
||||||
|
match "/"
|
||||||
|
match 0+ words or "_" or "-"
|
||||||
|
create an optional group
|
||||||
|
# we don't want to capture the '?', so don't name the group until afterwards
|
||||||
|
match "?"
|
||||||
|
create a group called query
|
||||||
|
repeat
|
||||||
|
match 1+ words or "_" or "-"
|
||||||
|
match "="
|
||||||
|
match 1+ words or "_" or "-"
|
||||||
|
create an optional group
|
||||||
|
# fragment, again, we don't care, so ignore everything afterwards
|
||||||
|
match "#"
|
||||||
|
match 0+ any thing
|
@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Our script -->
|
<!-- Our script -->
|
||||||
<script defer src="bundle.min.js"></script>
|
<script defer src="/bundle.min.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -4,19 +4,19 @@
|
|||||||
<head>
|
<head>
|
||||||
<!-- Metadata -->
|
<!-- Metadata -->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="{{page.description}}">
|
<meta name="description" content="{{description}}">
|
||||||
<meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language">
|
<meta name="keywords" content="Human2Regex, Human, Regex, Natural, Language, Natural Language">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
|
||||||
<title>{{page.title}}</title>
|
<title>{{title}}</title>
|
||||||
|
|
||||||
<!-- Our own CSS -->
|
<!-- Our own CSS -->
|
||||||
<link href="bundle.min.css" rel="stylesheet" type="text/css">
|
<link href="/bundle.min.css" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
<meta name="theme-color" content="#212529">
|
<meta name="theme-color" content="#212529">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a class="skip skip-top" href="#maincontent">Skip to main content</a>
|
<a class="skip skip-top" href="#maincontent">Skip to main content</a>
|
||||||
@ -25,14 +25,14 @@
|
|||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="index.html">
|
<a class="navbar-brand" href="/index.html">
|
||||||
<img src="favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex
|
<img src="/favicon-small.png" width="30" height="30" class="d-inline-block align-top" alt="logo"> Human2Regex
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="float-right heading-links">
|
<div class="float-right heading-links">
|
||||||
<a class="heading-link" href="index.html">Index</a>
|
<a class="heading-link" href="/index.html">Index</a>
|
||||||
<span> | </span>
|
<span> | </span>
|
||||||
<a class="heading-link" href="tutorial.html">Tutorial</a>
|
<a class="heading-link" href="/tutorial.html">Tutorial</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
64
src/docs/index.hbs
Normal file
64
src/docs/index.hbs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
||||||
|
|
||||||
|
{{> header title="Human2Regex" description="Create regular expressions with natural, human language"}}
|
||||||
|
<!-- Main Content -->
|
||||||
|
<div class="container" id="maincontent" role="main">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8 tenpx-margin-bottom">
|
||||||
|
<div class="form-group row zero-margin-bottom">
|
||||||
|
<label for="dialect" class="col-sm-4 col-form-label">Regex dialect:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control" id="dialect">
|
||||||
|
<option value="js" selected>Javascript</option>
|
||||||
|
<option value="dotnet">.NET</option>
|
||||||
|
<option value="python">Python</option>
|
||||||
|
<option value="boost">C++ Boost</option>
|
||||||
|
<option value="java">Java 7+</option>
|
||||||
|
<option value="pcre">PCRE</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h4>Your Regular Expression:</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-11 tenpx-margin-bottom">
|
||||||
|
<input readonly type="text" class="form-control" id="regex"></input>
|
||||||
|
</div>
|
||||||
|
<div class="col-xl-1">
|
||||||
|
<button type="button" class="btn btn-secondary float-right" id="clip">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4>Human Speak:</h4>
|
||||||
|
<textarea class="form-control" id="human" rows="25">{{> example_code}}</textarea>
|
||||||
|
<h4>Errors:</h4>
|
||||||
|
<textarea readonly class="form-control " id="errors" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="col-lg-4 tenpx-margin-bottom">
|
||||||
|
<div class="cheatsheet">
|
||||||
|
<h2>Cheat Sheet:</h2>
|
||||||
|
<p>Full documentation available <a href="/tutorial.html">here</a></p>
|
||||||
|
<p class="font-weight-bold">Matching</p>
|
||||||
|
<p>{{i-code}}match "hello world"{{end-i-code}} matches "hello world" exactly<p>
|
||||||
|
<p>{{i-code}}match "hello" then optionally " world"{{end-i-code}} matches "hello" or "hello world"</p>
|
||||||
|
<p>{{i-code}}match "hello" or "world"{{end-i-code}} matches "hello" or "world</p>
|
||||||
|
<p>{{i-code}}match a word{{end-i-code}} matches any word
|
||||||
|
<p class="font-weight-bold">Repetition</p>
|
||||||
|
<p>{{i-code}}match 0+ "hello"{{end-i-code}} matches 0 or more "hello"s</p>
|
||||||
|
<p>{{i-code}}match 3 "hello"{{end-i-code}} matches exactly "hellohellohello"</p>
|
||||||
|
<p>{{i-code}}match 1 to 5 "hello"{{end-i-code}} matches between 1 to 5 "hello"s</p>
|
||||||
|
<p>{{i-code}}repeat 0 or more{{end-i-code}} repeats the intended text 0 or more times (default)</p>
|
||||||
|
<p>{{i-code}}optionally repeat between 3 to 5{{end-i-code}} optionally repeats the indented text 3 to 5 times</p>
|
||||||
|
<p class="font-weight-bold">Grouping</p>
|
||||||
|
<p>{{i-code}}create a group called mygroup{{end-i-code}} creates a group called "mygroup"</p>
|
||||||
|
<p>{{i-code}}create an optional group{{end-i-code}} creates an unnamed optional group</p>
|
||||||
|
<p class="font-weight-bold">Using</p>
|
||||||
|
<p>{{i-code}}using global and case insensitive{{end-i-code}} uses the 'g' and 'i' flags</p>
|
||||||
|
<p class="font-weight-bold">Misc</p>
|
||||||
|
<p>{{i-code}}// comment{{end-i-code}} is a single line comment</p>
|
||||||
|
<p>{{i-code}}/* comment */{{end-i-code}} is a multi line comment</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{> footer}}
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"title": "Human2Regex",
|
|
||||||
"description": "Create regular expressions with natural, human language"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
|
||||||
|
|
||||||
{{> header}}
|
|
||||||
<!-- Main Content -->
|
|
||||||
<div class="container" id="maincontent" role="main">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-8 tenpx-margin-bottom">
|
|
||||||
<div class="form-group row zero-margin-bottom">
|
|
||||||
<label for="dialect" class="col-sm-4 col-form-label">Regex dialect:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select class="form-control" id="dialect">
|
|
||||||
<option value="js" selected>Javascript</option>
|
|
||||||
<option value="dotnet">.NET</option>
|
|
||||||
<option value="python">Python</option>
|
|
||||||
<option value="boost">C++ Boost</option>
|
|
||||||
<option value="java">Java 7+</option>
|
|
||||||
<option value="pcre">PCRE</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h4>Your Regular Expression:</h4>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xl-11 tenpx-margin-bottom">
|
|
||||||
<input readonly type="text" class="form-control" id="regex"></input>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl-1">
|
|
||||||
<button type="button" class="btn btn-secondary float-right" id="clip">Copy</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4>Human Speak:</h4>
|
|
||||||
<textarea class="form-control" id="human" rows="25">
|
|
||||||
/* Make a regex that matches (basic) URLs */
|
|
||||||
|
|
||||||
using global and exact matching
|
|
||||||
create an optional group called protocol
|
|
||||||
match "http"
|
|
||||||
possibly match "s"
|
|
||||||
match "://"
|
|
||||||
create an optional group called subdomain
|
|
||||||
repeat
|
|
||||||
match a word, then "."
|
|
||||||
create a group called domain
|
|
||||||
match 1+ words or "_" or "-"
|
|
||||||
match "."
|
|
||||||
match a word
|
|
||||||
# port, but we don't care about it, so ignore it
|
|
||||||
optionally match ":" then 0+ digits
|
|
||||||
create an optional group called path
|
|
||||||
repeat
|
|
||||||
match "/"
|
|
||||||
match 0+ words or "_" or "-"
|
|
||||||
create an optional group
|
|
||||||
# we don't want to capture the '?', so don't name the group until afterwards
|
|
||||||
match "?"
|
|
||||||
create a group called query
|
|
||||||
repeat
|
|
||||||
match 1+ words or "_" or "-"
|
|
||||||
match "="
|
|
||||||
match 1+ words or "_" or "-"
|
|
||||||
create an optional group
|
|
||||||
# fragment, again, we don't care, so ignore everything afterwards
|
|
||||||
match "#"
|
|
||||||
match 0+ any thing
|
|
||||||
</textarea>
|
|
||||||
<h4>Errors:</h4>
|
|
||||||
<textarea readonly class="form-control " id="errors" rows="5"></textarea>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="col-lg-4 tenpx-margin-bottom">
|
|
||||||
<div class="cheatsheet">
|
|
||||||
<h2>Cheat Sheet:</h2>
|
|
||||||
<p>Full documentation available <a href="tutorial.html">here</a></p>
|
|
||||||
<p class="font-weight-bold">Matching</p>
|
|
||||||
<p><code class="cm-s-idea">match "hello world"</code> matches "hello world" exactly<p>
|
|
||||||
<p><code class="cm-s-idea">match "hello" then optionally " world"</code> matches "hello" or "hello world"</p>
|
|
||||||
<p><code class="cm-s-idea">match "hello" or "world"</code> matches "hello" or "world</p>
|
|
||||||
<p><code class="cm-s-idea">match a word</code> matches any word
|
|
||||||
<p class="font-weight-bold">Repetition</p>
|
|
||||||
<p><code class="cm-s-idea">match 0+ "hello"</code> matches 0 or more "hello"s</p>
|
|
||||||
<p><code class="cm-s-idea">match 3 "hello"</code> matches exactly "hellohellohello"</p>
|
|
||||||
<p><code class="cm-s-idea">match 1 to 5 "hello"</code> matches between 1 to 5 "hello"s</p>
|
|
||||||
<p><code class="cm-s-idea">repeat 0 or more</code> repeats the intended text 0 or more times (default)</p>
|
|
||||||
<p><code class="cm-s-idea">optionally repeat between 3 to 5</code> optionally repeats the indented text 3 to 5 times</p>
|
|
||||||
<p class="font-weight-bold">Grouping</p>
|
|
||||||
<p><code class="cm-s-idea">create a group called mygroup</code> creates a group called "mygroup"</p>
|
|
||||||
<p><code class="cm-s-idea">create an optional group</code> creates an unnamed optional group</p>
|
|
||||||
<p class="font-weight-bold">Using</p>
|
|
||||||
<p><code class="cm-s-idea">using global and case insensitive</code> uses the 'g' and 'i' flags</p>
|
|
||||||
<p class="font-weight-bold">Misc</p>
|
|
||||||
<p><code class="cm-s-idea">// comment</code> is a single line comment</p>
|
|
||||||
<p><code class="cm-s-idea">/* comment */</code> is a multi line comment</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{> footer}}
|
|
@ -1,6 +1,6 @@
|
|||||||
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
{{! Copyright (c) 2021 Patrick Demian; Licensed under MIT }}
|
||||||
|
|
||||||
{{> header}}
|
{{> header title="Human2Regex Tutorial" description="Create regular expressions with natural, human language"}}
|
||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<div class="container contained-container" id="maincontent" role="main">
|
<div class="container contained-container" id="maincontent" role="main">
|
||||||
<div id="tutorial">
|
<div id="tutorial">
|
||||||
@ -12,32 +12,31 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-first-match">1. Your first Match</p>
|
<p class="font-weight-bold" id="tut-first-match">1. Your first Match</p>
|
||||||
<p>Every language starts with a "Hello World" program, so let's match the output of those programs. Matching is done using the keyword <code class="cm-s-idea">match</code> followed by what you want to match.
|
<p>Every language starts with a "Hello World" program, so let's match the output of those programs. Matching is done using the keyword {{i-code}}match{{end-i-code}} followed by what you want to match.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "Hello World"
|
match "Hello World"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
The above statement will generate a regular expression that matches "Hello World", like "/Hello World/". Any invalid characters will automatically be escaped, so you don't need to worry about it. H2R also supports block comments with <code class="cm-s-idea">/**/</code>, or line comments with <code class="cm-s-idea">//</code> or <code class="cm-s-idea">#</code> so you can explain why or what you intend to match.</p>
|
The above statement will generate a regular expression that matches "Hello World", like "/Hello World/". Any invalid characters will automatically be escaped, so you don't need to worry about it. H2R also supports block comments with {{i-code}}/**/{{end-i-code}}, or line comments with {{i-code}}//{{end-i-code}} or {{i-code}}#{{end-i-code}} so you can explain why or what you intend to match.</p>
|
||||||
<pre class="tutorial-code"><code class="cm-s-idea">/* This is a block comment */
|
{{p-code}}/* This is a block comment */
|
||||||
match "Hello World" // matches the output of "Hello World" programs
|
match "Hello World" // matches the output of "Hello World" programs
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>Now what if we want to match every case variation of "Hello World" like "hello world" or "hELLO wORLD"? H2R supports the <code class="cm-s-idea">or</code> operator which allows you to specify many possible combinations.
|
<p>Now what if we want to match every case variation of "Hello World" like "hello world" or "hELLO wORLD"? H2R supports the {{i-code}}or{{end-i-code}} operator which allows you to specify many possible combinations.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "Hello World" or "hello world" or "hELLO wORLD"
|
match "Hello World" or "hello world" or "hELLO wORLD"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
Or, you can use a <code class="cm-s-idea">using</code> statement to specify that you want it to be case insensitive.</p>
|
Or, you can use a {{i-code}}using{{end-i-code}} statement to specify that you want it to be case insensitive.</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-using">2. Using Specifiers</p>
|
<p class="font-weight-bold" id="tut-using">2. Using Specifiers</p>
|
||||||
<p>Using statements appear at the beginning. You may have one or more using statements which each can contain one or more specifiers. For example:
|
<p>Using statements appear at the beginning. You may have one or more using statements which each can contain one or more specifiers. For example:
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
using global and case insensitive matching
|
using global and case insensitive matching
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or</p>
|
or</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}using global
|
||||||
<code class="cm-s-idea">using global
|
|
||||||
using case insensitive
|
using case insensitive
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>The <code class="cm-s-idea">matching</code> keyword is optional. The flags which are available are:</p>
|
<p>The {{i-code}}matching{{end-i-code}} keyword is optional. The flags which are available are:</p>
|
||||||
|
|
||||||
<table class="table table-sm table-striped table-bordered">
|
<table class="table table-sm table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
@ -49,27 +48,27 @@ using case insensitive
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">multiline</code></td>
|
<td>{{i-code}}multiline{{end-i-code}}</td>
|
||||||
<td>Matches can cross line breaks</td>
|
<td>Matches can cross line breaks</td>
|
||||||
<td>/<your regex>/m</td>
|
<td>/<your regex>/m</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">global</code></td>
|
<td>{{i-code}}global{{end-i-code}}</td>
|
||||||
<td>Multiple matches are allowed</td>
|
<td>Multiple matches are allowed</td>
|
||||||
<td>/<your regex>/g</td>
|
<td>/<your regex>/g</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">case sensitive</code></td>
|
<td>{{i-code}}case sensitive{{end-i-code}}</td>
|
||||||
<td>Match must be exact case</td>
|
<td>Match must be exact case</td>
|
||||||
<td><span class="font-italic">none</span></td>
|
<td><span class="font-italic">none</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">case insensitive</code></td>
|
<td>{{i-code}}case insensitive{{end-i-code}}</td>
|
||||||
<td>Match may be any case</td>
|
<td>Match may be any case</td>
|
||||||
<td>/<your regex>/i</td>
|
<td>/<your regex>/i</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">exact</code></td>
|
<td>{{i-code}}exact{{end-i-code}}</td>
|
||||||
<td>An exact statement matches a whole line exactly, nothing before, nothing after</td>
|
<td>An exact statement matches a whole line exactly, nothing before, nothing after</td>
|
||||||
<td>/^<your regex>$/</td>
|
<td>/^<your regex>$/</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -77,70 +76,69 @@ using case insensitive
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>To match any variation of hello world, we would then do the following:</p>
|
<p>To match any variation of hello world, we would then do the following:</p>
|
||||||
<pre class="tutorial-code"><code class="cm-s-idea">using case insensitive matching
|
<pre class="tutorial-code">{{i-code}}using case insensitive matching
|
||||||
match "hello world"
|
match "hello world"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-multiple-match">3. Matching multiple items</p>
|
<p class="font-weight-bold" id="tut-multiple-match">3. Matching multiple items</p>
|
||||||
<p>H2R comes with 2 options to match multiple items in a row. The first is to simply write multiple separate <code class="cm-s-idea">match</code> statements like:</p>
|
<p>H2R comes with 2 options to match multiple items in a row. The first is to simply write multiple separate {{i-code}}match{{end-i-code}} statements like:</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}match "hello"
|
||||||
<code class="cm-s-idea">match "hello"
|
|
||||||
match " "
|
match " "
|
||||||
match "world"
|
match "world"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>However, you can also use a comma, <code class="cm-s-idea">and</code>, or <code class="cm-s-idea">then</code> for a more concise match.
|
<p>However, you can also use a comma, {{i-code}}and{{end-i-code}}, or {{i-code}}then{{end-i-code}} for a more concise match.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "hello", " ", "world"
|
match "hello", " ", "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "hello" and " " and "world"
|
match "hello" and " " and "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "hello" then " " then "world"
|
match "hello" then " " then "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or any combination like
|
or any combination like
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "hello", " " and then "world"
|
match "hello", " " and then "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-optionality">4. Optionality</p>
|
<p class="font-weight-bold" id="tut-optionality">4. Optionality</p>
|
||||||
<p>Sometimes you wish to match something that may or may not exist. In H2R, this is done via the <code class="cm-s-idea">optional</code>, <code class="cm-s-idea">optionally</code>, <code class="cm-s-idea">possibly</code> or <code class="cm-s-idea">maybe</code> keyword.
|
<p>Sometimes you wish to match something that may or may not exist. In H2R, this is done via the {{i-code}}optional{{end-i-code}}, {{i-code}}optionally{{end-i-code}}, {{i-code}}possibly{{end-i-code}} or {{i-code}}maybe{{end-i-code}} keyword.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
optionally match "hello world"
|
optionally match "hello world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match 0 or 1 "hello world"'s. This can be used alongside matching multiple statements in a single <code class="cm-s-idea">match</code> statement.
|
will match 0 or 1 "hello world"'s. This can be used alongside matching multiple statements in a single {{i-code}}match{{end-i-code}} statement.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "hello", maybe " ", "world"
|
match "hello", maybe " ", "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match "hello", an optional space if it exists, and "world". However, the start <code class="cm-s-idea">optional</code> is for the entire match statement. Thus,
|
will match "hello", an optional space if it exists, and "world". However, the start {{i-code}}optional{{end-i-code}} is for the entire match statement. Thus,
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
possibly match "hello", " ", then "world"
|
possibly match "hello", " ", then "world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will actually make the whole "hello world" an optional match rather than just the first "hello". If you want to make the first match optional but keep the rest required, place the <code class="cm-s-idea">optional</code> immediately after the <code class="cm-s-idea">match</code>.</p>
|
will actually make the whole "hello world" an optional match rather than just the first "hello". If you want to make the first match optional but keep the rest required, place the {{i-code}}optional{{end-i-code}} immediately after the {{i-code}}match{{end-i-code}}.</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-negation">5. Negation</p>
|
<p class="font-weight-bold" id="tut-negation">5. Negation</p>
|
||||||
<p>You can negate a match with the operator <code class="cm-s-idea">not</code>
|
<p>You can negate a match with the operator {{i-code}}not{{end-i-code}}
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match not "hello world"
|
match not "hello world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match anything but "hello world"
|
match anything but "hello world"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match everything except for "hello world".</p>
|
will match everything except for "hello world".</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-other-match">6. Other matching specifiers</p>
|
<p class="font-weight-bold" id="tut-other-match">6. Other matching specifiers</p>
|
||||||
<p>Many times you don't know exactly what you wish to match. H2R comes with many specifiers that you can use for your matching. For example, you may wish to match any word. You can do that with:
|
<p>Many times you don't know exactly what you wish to match. H2R comes with many specifiers that you can use for your matching. For example, you may wish to match any word. You can do that with:
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match a word
|
match a word
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
The <code class="cm-s-idea">a</code> or <code class="cm-s-idea">an</code> is optional. The possible specifiers that H2R supports are the following:</p>
|
The {{i-code}}a{{end-i-code}} or {{i-code}}an{{end-i-code}} is optional. The possible specifiers that H2R supports are the following:</p>
|
||||||
<table class="table table-sm table-striped table-bordered">
|
<table class="table table-sm table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -152,71 +150,71 @@ match a word
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">anything</code></td>
|
<td>{{i-code}}anything{{end-i-code}}</td>
|
||||||
<td>Matches any character</td>
|
<td>Matches any character</td>
|
||||||
<td>.</td>
|
<td>.</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">word(s)</code></td>
|
<td>{{i-code}}word(s){{end-i-code}}</td>
|
||||||
<td>Matches many a-z, A-Z, _, or digit characters</td>
|
<td>Matches many a-z, A-Z, _, or digit characters</td>
|
||||||
<td>\w+</td>
|
<td>\w+</td>
|
||||||
<td>For a-z only, use <code class="cm-s-idea">letter(s)</code></td>
|
<td>For a-z only, use {{i-code}}letter(s){{end-i-code}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">letter(s)</code></td>
|
<td>{{i-code}}letter(s){{end-i-code}}</td>
|
||||||
<td>Matches any letter character</td>
|
<td>Matches any letter character</td>
|
||||||
<td>[a-zA-Z]</td>
|
<td>[a-zA-Z]</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">number(s)</code></td>
|
<td>{{i-code}}number(s){{end-i-code}}</td>
|
||||||
<td>Matches a string of digit characters</td>
|
<td>Matches a string of digit characters</td>
|
||||||
<td>\d+</td>
|
<td>\d+</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">digit(s)</code></td>
|
<td>{{i-code}}digit(s){{end-i-code}}</td>
|
||||||
<td>Matches any digit character</td>
|
<td>Matches any digit character</td>
|
||||||
<td>\d</td>
|
<td>\d</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">integer(s)</code></td>
|
<td>{{i-code}}integer(s){{end-i-code}}</td>
|
||||||
<td>Matches an integer</td>
|
<td>Matches an integer</td>
|
||||||
<td>[+-]?\d+</td>
|
<td>[+-]?\d+</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">decimal(s)</code></td>
|
<td>{{i-code}}decimal(s){{end-i-code}}</td>
|
||||||
<td>Matches digits, an optional decimal point and more digits</td>
|
<td>Matches digits, an optional decimal point and more digits</td>
|
||||||
<td>[+-]?((\d+[,.]?\d*)|([,.]\d+))</td>
|
<td>[+-]?((\d+[,.]?\d*)|([,.]\d+))</td>
|
||||||
<td>Supports both "," and "." decimal points</td>
|
<td>Supports both "," and "." decimal points</td>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">character(s)</code></td>
|
<td>{{i-code}}character(s){{end-i-code}}</td>
|
||||||
<td>Matches a-z, A-Z, _, or digits</td>
|
<td>Matches a-z, A-Z, _, or digits</td>
|
||||||
<td>\w</td>
|
<td>\w</td>
|
||||||
<td>For a-z only, use <code class="cm-s-idea">letter(s)</code></td>
|
<td>For a-z only, use {{i-code}}letter(s){{end-i-code}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">whitespace(s)</code></td>
|
<td>{{i-code}}whitespace(s){{end-i-code}}</td>
|
||||||
<td>Matches any whitespace character</td>
|
<td>Matches any whitespace character</td>
|
||||||
<td>\s</td>
|
<td>\s</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">(word )boundary</code></td>
|
<td>{{i-code}}(word )boundary{{end-i-code}}</td>
|
||||||
<td>Boundary between a word</td>
|
<td>Boundary between a word</td>
|
||||||
<td>\b</td>
|
<td>\b</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">line feed</code>/<code class="cm-s-idea">newline</code></td>
|
<td>{{i-code}}line feed{{end-i-code}}/{{i-code}}newline{{end-i-code}}</td>
|
||||||
<td>Matches a newline</td>
|
<td>Matches a newline</td>
|
||||||
<td>\n</td>
|
<td>\n</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code class="cm-s-idea">carriage return</code></td>
|
<td>{{i-code}}carriage return{{end-i-code}}</td>
|
||||||
<td>Matches a carriage return</td>
|
<td>Matches a carriage return</td>
|
||||||
<td>\r</td>
|
<td>\r</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
@ -225,111 +223,103 @@ match a word
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>You can also create ranges of characters to match. Say for example, you wanted to match any characters between a and z, you could write any of the following:
|
<p>You can also create ranges of characters to match. Say for example, you wanted to match any characters between a and z, you could write any of the following:
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match from "a" to "z" // "from" is optional
|
match from "a" to "z" // "from" is optional
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match between "a" and "z" // "between" is optional
|
match between "a" and "z" // "between" is optional
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "a" ... "z" // can use "..." or ".."
|
match "a" ... "z" // can use "..." or ".."
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "a" - "z"
|
match "a" - "z"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "a" through "z" // can also use thru
|
match "a" through "z" // can also use thru
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-repeition">7. Repetition</p>
|
<p class="font-weight-bold" id="tut-repeition">7. Repetition</p>
|
||||||
<p>H2R supports 2 types of repetition: single match repetition, or grouped repetition. When using <code class="cm-s-idea">match</code> you can specify the number of captures you want just before the text to capture.
|
<p>H2R supports 2 types of repetition: single match repetition, or grouped repetition. When using {{i-code}}match{{end-i-code}} you can specify the number of captures you want just before the text to capture.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2 digits
|
match 2 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match exactly 2 digits
|
match exactly 2 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match any 2 digits in a row. You can also specify a range you wish to capture
|
will match any 2 digits in a row. You can also specify a range you wish to capture
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2 ... 5 digits
|
match 2 ... 5 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2 to 5 digits
|
match 2 to 5 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match between 2 to 5 digits
|
match between 2 to 5 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match 2, 3, 4, or 5 digits. You can specify if the final number is exclusive with the <code class="cm-s-idea">exclusive</code> or <code class="cm-s-idea">inclusive</code> keywords.
|
will match 2, 3, 4, or 5 digits. You can specify if the final number is exclusive with the {{i-code}}exclusive{{end-i-code}} or {{i-code}}inclusive{{end-i-code}} keywords.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2 to 5 exclusive digits
|
match 2 to 5 exclusive digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will only match up to 4 digits. You can also choose to leave the end unspecified.
|
will only match up to 4 digits. You can also choose to leave the end unspecified.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2+ digits
|
match 2+ digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
or
|
or
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 2 or more digits
|
match 2 or more digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
will match 2 or more digits. Repeition can be chained with the <code class="cm-s-idea">and then</code> keywords or the <code class="cm-s-idea">optional</code> keyword. For example:
|
will match 2 or more digits. Repeition can be chained with the {{i-code}}and then{{end-i-code}} keywords or the {{i-code}}optional{{end-i-code}} keyword. For example:
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match 1+ digits then optionally "." then optionally 0...8 digits
|
match 1+ digits then optionally "." then optionally 0...8 digits
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
|
|
||||||
Suppose you want to repeat a group of these match statements. You can group a repetition using the <code class="cm-s-idea">repeat</code> keyword. Everything underneath that is tabbed (scoped) will be repeated. By default, this will match 0 or more of the following statements.</p>
|
Suppose you want to repeat a group of these match statements. You can group a repetition using the {{i-code}}repeat{{end-i-code}} keyword. Everything underneath that is tabbed (scoped) will be repeated. By default, this will match 0 or more of the following statements.</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}repeat
|
||||||
<code class="cm-s-idea">repeat
|
|
||||||
match "Hello "
|
match "Hello "
|
||||||
match "World"
|
match "World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>Will match 0 or more "Hello "s, but only 1 "World". The same qualifiers that exist for <code class="cm-s-idea">match</code> statements also exist for <code class="cm-s-idea">repeat</code> statements.</p>
|
<p>Will match 0 or more "Hello "s, but only 1 "World". The same qualifiers that exist for {{i-code}}match{{end-i-code}} statements also exist for {{i-code}}repeat{{end-i-code}} statements.</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}optionally repeat 3...7 times
|
||||||
<code class="cm-s-idea">optionally repeat 3...7 times
|
|
||||||
match "Hello World"
|
match "Hello World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>Will potentially match "Hello World" between 3 and 7 times. H2R also supports the following for numbers: <code class="cm-s-idea">One, Two, Three, Four, Five, Six, Seven, Eight, Nine, and Ten</code></p>
|
<p>Will potentially match "Hello World" between 3 and 7 times. H2R also supports the following for numbers: {{i-code}}One, Two, Three, Four, Five, Six, Seven, Eight, Nine, and Ten{{end-i-code}}</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p class="font-weight-bold" id="tut-grouping">8. Grouping</p>
|
<p class="font-weight-bold" id="tut-grouping">8. Grouping</p>
|
||||||
<p>Just like regular expressions, capture groups are supported in H2R. Each group is defined using the <code class="cm-s-idea">create a group</code> keyphrase.</p>
|
<p>Just like regular expressions, capture groups are supported in H2R. Each group is defined using the {{i-code}}create a group{{end-i-code}} keyphrase.</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}create a group
|
||||||
<code class="cm-s-idea">create a group
|
|
||||||
match "Hello World"
|
match "Hello World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>This will create a non-named captured group, equivalent to the regular expression "/(Hello World)/". A non-named captured group will show up in your chosen language's matches, however will not be given a name. To access this match, you will need to know the index of the group. Most regular expression engines support named capture groups, and H2R highly recommends using this feature. If you wish to do so, simply give it a name:<p>
|
<p>This will create a non-named captured group, equivalent to the regular expression "/(Hello World)/". A non-named captured group will show up in your chosen language's matches, however will not be given a name. To access this match, you will need to know the index of the group. Most regular expression engines support named capture groups, and H2R highly recommends using this feature. If you wish to do so, simply give it a name:<p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}create a group called TestGroup
|
||||||
<code class="cm-s-idea">create a group called TestGroup
|
|
||||||
match "Hello World"
|
match "Hello World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>In most languages, a named group can be accessed through the match result's group list. Take for example, in JavaScript,
|
<p>In most languages, a named group can be accessed through the match result's group list. Take for example, in JavaScript,
|
||||||
<pre class="tutorial-code">
|
{{p-code}}"hello".match(/(?<TestGroup>hello)/).groups
|
||||||
<code class="cm-s-idea">"hello".match(/(?<TestGroup>hello)/).groups</code>
|
{{end-p-code}}
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Will return an object with {TestGroup: "hello"}. For another example, check out <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#Using_named_capturing_groups">MDN web docs</a>. Groups can also be optional.</p>
|
<p>Will return an object with {TestGroup: "hello"}. For another example, check out <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#Using_named_capturing_groups">MDN web docs</a>. Groups can also be optional.</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}create an optional group
|
||||||
<code class="cm-s-idea">create an optional group
|
|
||||||
match "Hello World"
|
match "Hello World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>And groups may be nested</p>
|
<p>And groups may be nested</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}create a group called TestGroup
|
||||||
<code class="cm-s-idea">create a group called TestGroup
|
|
||||||
match "Hello"
|
match "Hello"
|
||||||
create a group called InnerGroup
|
create a group called InnerGroup
|
||||||
match "World"
|
match "World"
|
||||||
</code></pre>
|
{{end-p-code}}
|
||||||
<p>The regular expression returned by this will be "/(?<TestGroup>Hello(?<InnerGroup>World))/". Again, in JavaScript, the following</p>
|
<p>The regular expression returned by this will be "/(?<TestGroup>Hello(?<InnerGroup>World))/". Again, in JavaScript, the following</p>
|
||||||
<pre class="tutorial-code">
|
{{p-code}}"HelloWorld".match(/(?<TestGroup>Hello(?<InnerGroup>World))/).groups
|
||||||
<code class="cm-s-idea">"HelloWorld".match(/(?<TestGroup>Hello(?<InnerGroup>World))/).groups</code>
|
{{end-p-code}}
|
||||||
</pre>
|
|
||||||
<p>Will return an object with {TestGroup: "HelloWorld", InnerGroup: "World"}.</p>
|
<p>Will return an object with {TestGroup: "HelloWorld", InnerGroup: "World"}.</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -345,18 +335,18 @@ match "World"
|
|||||||
<p>TODO</p>
|
<p>TODO</p>
|
||||||
|
|
||||||
<p class="font-weight-bold" id="tut-unicode">Unicode character properties</p>
|
<p class="font-weight-bold" id="tut-unicode">Unicode character properties</p>
|
||||||
<p>You can match specific unicode sequences using <code class="cm-s-idea">"\uXXXX"
|
<p>You can match specific unicode sequences using {{i-code}}"\uXXXX"
|
||||||
</code> or <code class="cm-s-idea">"\UXXXXXXXX"</code> where X is a hexadecimal character.
|
{{end-i-code}} or {{i-code}}"\UXXXXXXXX"{{end-i-code}} where X is a hexadecimal character.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match "\u0669" // matches arabic digit 9 "٩"
|
match "\u0669" // matches arabic digit 9 "٩"
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
Unicode character classes/scripts can be matched using the <code class="cm-s-idea">unicode</code> keyword.
|
Unicode character classes/scripts can be matched using the {{i-code}}unicode{{end-i-code}} keyword.
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match unicode "Latin" // matches any latin character
|
match unicode "Latin" // matches any latin character
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
<span class="tutorial-code"><code class="cm-s-idea">
|
{{s-code}}
|
||||||
match unicode "N" // matches any number character
|
match unicode "N" // matches any number character
|
||||||
</code></span>
|
{{end-s-code}}
|
||||||
The following Unicode class specifiers are available:</p>
|
The following Unicode class specifiers are available:</p>
|
||||||
<table class="table table-sm table-striped table-bordered">
|
<table class="table table-sm table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"title": "Human2Regex Tutorial",
|
|
||||||
"description": "Create regular expressions with natural, human language"
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,10 +4,10 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { glob } = require("glob");
|
const { glob } = require("glob");
|
||||||
const { render } = require("mustache");
|
|
||||||
const { readFileSync, writeFileSync, existsSync, mkdirSync } = require("fs");
|
const { readFileSync, writeFileSync, existsSync, mkdirSync } = require("fs");
|
||||||
const { minify } = require("html-minifier");
|
const { minify } = require("html-minifier");
|
||||||
const CopyPlugin = require("copy-webpack-plugin");
|
const CopyPlugin = require("copy-webpack-plugin");
|
||||||
|
const Handlebars = require("handlebars");
|
||||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
||||||
const WebpackBeforeBuildPlugin = require("before-build-webpack");
|
const WebpackBeforeBuildPlugin = require("before-build-webpack");
|
||||||
@ -32,32 +32,62 @@ const config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function build_mustache() {
|
function build_handlebars() {
|
||||||
if (!existsSync(config.dst)){
|
if (!existsSync(config.dst)){
|
||||||
mkdirSync(config.dst);
|
mkdirSync(config.dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
const read_json_file = (filename) => JSON.parse(readFileSync(filename), "utf8");
|
const files = [
|
||||||
|
"404.hbs",
|
||||||
|
"index.hbs",
|
||||||
|
"tutorial.hbs"
|
||||||
|
];
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
build: {
|
||||||
|
prod: config.prod+"",
|
||||||
|
year: new Date().getFullYear()+""
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const compress_html = (input) => config.prod ? minify(input, config.compression_config.html) : input;
|
// helper functions
|
||||||
|
const compress_html = (input) => config.prod ? minify(input, config.compression_config.html) : input;
|
||||||
|
|
||||||
// get views
|
Handlebars.registerHelper("i-code", function(options) {
|
||||||
const files = glob.sync(path.join(config.src, "docs", "*.json"));
|
return new Handlebars.SafeString(`<code class="cm-s-idea">`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("s-code", function(options) {
|
||||||
|
return new Handlebars.SafeString(`<span class="tutorial-code"><code class="cm-s-idea">`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("p-code", function(options) {
|
||||||
|
return new Handlebars.SafeString(`<pre class="tutorial-code"><code class="cm-s-idea">`);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("end-i-code", function(options) {
|
||||||
|
return new Handlebars.SafeString('</code>');
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("end-s-code", function(options) {
|
||||||
|
return new Handlebars.SafeString('</code></span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("end-p-code", function(options) {
|
||||||
|
return new Handlebars.SafeString('</code></pre>');
|
||||||
|
});
|
||||||
|
|
||||||
// get partials
|
// get partials
|
||||||
const partials = {
|
Handlebars.registerPartial("header", readFileSync(path.join(config.src, "docs", "header.hbs"), "utf8"));
|
||||||
header: readFileSync(path.join(config.src, "docs", "header.mustache"), "utf8"),
|
Handlebars.registerPartial("footer", readFileSync(path.join(config.src, "docs", "footer.hbs"), "utf8"));
|
||||||
footer: readFileSync(path.join(config.src, "docs", "footer.mustache"), "utf8")
|
Handlebars.registerPartial("example_code", readFileSync(path.join(config.src, "docs", "example_code.hbs"), "utf8"));
|
||||||
};
|
|
||||||
|
// build handlebar files
|
||||||
|
for (const filename of files) {
|
||||||
|
const to = path.join(config.dst, path.basename(filename, ".hbs") + ".html");
|
||||||
|
const template = readFileSync(path.join(config.src, "docs", filename), "utf8");
|
||||||
|
|
||||||
// build main mustache files
|
writeFileSync(to, compress_html(Handlebars.compile(template)(context)));
|
||||||
for (const item of files) {
|
|
||||||
const filename = path.basename(item, ".json");
|
|
||||||
const view = read_json_file(item);
|
|
||||||
const to = path.join(config.dst, filename + ".html");
|
|
||||||
const template = readFileSync(path.join(config.src, "docs", filename + ".mustache"), "utf8");
|
|
||||||
|
|
||||||
writeFileSync(to, compress_html(render(template, view, partials)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,12 +114,12 @@ module.exports = {
|
|||||||
plugins: [
|
plugins: [
|
||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{ from: config.src + "docs/" + "!(*.css|*.mustache|*.json)", to: "", flatten: true}
|
{ from: config.src + "docs/" + "!(*.css|*.hbs)", to: "", flatten: true}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
new MiniCssExtractPlugin({ filename: "bundle.min.css" }),
|
new MiniCssExtractPlugin({ filename: "bundle.min.css" }),
|
||||||
new WebpackBeforeBuildPlugin(function(_, callback) {
|
new WebpackBeforeBuildPlugin(function(_, callback) {
|
||||||
build_mustache();
|
build_handlebars();
|
||||||
callback();
|
callback();
|
||||||
}),
|
}),
|
||||||
new RemovePlugin({
|
new RemovePlugin({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user