Syntax
What makes Regcode
special is the simple syntax. Anyone with basic knowledge of coding and English will have no problems in understanding and creating Regcode expressions.
Elements
A Regcode expression contains several definitions that will be held separate with whitespaces. These contain definitions like methods
, flags
, quantifiers
and values
. It looks something like this.
<flag> method(parameter)[or][value] [value]{quantifier}
Tihs simple syntax allows you to create your own expression in a matter of minutes. The example below will match the boy
or the girl
, in which the first letter t
's casing does not matter.
// regcode
<matchAll> [start] normal(T[or]the) [whitespace]{1,2} normal(boy)[or]normal(girl) [end]
// regex
/^(?:T|t)he\s{1,2}(?:boy|girl)$/g
Flags
<matchAll>
, <unicode>
, <multiline>
and more...
Flags allow you to modify the settings of your search. This is often placed in the beginning of a Regcode statement.
Values
[number]
, [character]
, [whitespace]
, [start]
and more...
One of the most important part of regcode. Represents the base values you can use in a statement. It is possible to place them directly in the code or as arguments to methods.
Methods
normal()
, exact()
, regex()
, oneOf()
and more...
Methods lets you pass in your own data to use. All different method does different thing with your arguments. Most methods will escape characters (like .
) for you as well, so you don't have to worry about it.
Quantifiers
{3}
, {any}
, {optional}
, {optional-short}
and more...
A quantifier can be appended to most types, as it quantifies how many times it can occur. There are several different ways to write them. The most important part is that you place them directly after the statement, without space.
Or
[or]
and [or{2}]
Or will let you choose to match between two or more alternatives. It can be used both directly in the statement or as method parameters.
All or-statements needs to be chained together without whitespace, like so:
[number][or]oneOf(abc)
In case you want to use a quantifier on a full or-statement, use the [or{quantifer}]
syntax.
[number][or]oneOf(abc)[or{3}]