dev-master
9999999-dev
MIT
The Development Requires
v0.2.2
0.2.2.0
MIT
The Development Requires
0.2.x-dev
0.2.9999999.9999999-dev
MIT
The Development Requires
v0.2.1
0.2.1.0
MIT
The Development Requires
v0.2
0.2.0.0
MIT
The Development Requires
Wallogit.com
2017 © Pedro Peláez
ExpExp expands expressions. That's kinda the opposite of what regular expressions do., (*1)
For example ab(cd|[xy]) expands to, (*2)
abcd,abx andaby.The following expressions can be expanded by the library:, (*4)
Disjunction:, (*5)
abc[xyz]
will be expanded to, (*6)
abcxabcyabczNamed character classes:, (*7)
Instead of listing all disjunct characters, you can also select from a set of available character classes:, (*8)
upper contains uppercase characters (from ASCII)lower contains lowercase characters (from ASCII)digit contains digitsspace contains space characterspunct contains punctuation charactersYou can use named character classes by wrapping them in colons:, (*9)
[:upper:]
Dot Operator:, (*10)
abc.
will be expanded to, (*11)
abcAabcBThe Dot opterator does not expand to every character, but only to A-Za-z0-9_., (*12)
Parantheses:, (*13)
ab(c)
will be expanded to, (*14)
abcRepetition:, (*15)
The repetition operator allows to repeat the previous character(s). If only one value is given the previous character is repeated that often, if two values are given the character is multiplied with each value in the given range. {,3} is the same as {0,3}., (*16)
a{3}
will expand to, (*17)
aaaOr with a minimum and a maximum value:, (*18)
a{1,3}
will expand to, (*19)
aaaaaaThis also works with disjunctions and parentheses., (*20)
Alternation:, (*21)
abc|xyz
will be expanded to, (*22)
abcxyzOptional:, (*23)
abc?
will be expanded to, (*24)
abcabThis also works with parantheses:, (*25)
abc(xyz)?
will be expanded to, (*26)
abcabcxyzThe optional operator has thus the same effect as {0,1}., (*27)
| Pattern | Count | Expansion |
|---|---|---|
abc |
1 | abc |
ab(c) |
1 | abc |
[abc] |
3 |
a, b, c
|
a{3} |
1 | aaa |
a{} |
1 | a |
a{1,3} |
3 |
a, aa, aaa
|
a{,3} |
4 |
, a, aa, aaa
|
a(bc){2} |
1 | abcbc |
a(bc){1,2} |
2 |
abcbc, abc
|
a(bc){,2} |
3 |
a, abc, abcbc
|
[ab]{2} |
2 |
aa, bb
|
ab. |
63 |
abA, abB, aba, ab0, ab_, ... |
abc|xyz |
2 |
abc, xyz
|
a|b|c |
3 |
a, b, c
|
ab(c|d) |
2 |
abc, abd
|
ab(cde|[xyz]) |
4 |
abcde, abx, aby, abz
|
abc? |
2 |
abc, ab
|
abc(xyz)? |
2 |
abc, abcxyz
|
Instantiate the object and call the expand() method with the pattern:, (*28)
use Bc\ExpExp\ExpExp;
$e = new ExpExp();
$result = $e->expand('abc|xyz');
More examples can be found in the test cases., (*29)
word character classBraincrafted
{}
Bc namespaceexpand() with patternExpExp is licensed under The MIT License. See the LICENSE file in the projects root directory for more information., (*30)
MIT
MIT
MIT
MIT
MIT