Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /
- ^ # start of string
- ( # first group start
- (?:
- (?:[^?+*{}()[]\|]+ # literals and ^, $
- | \. # escaped characters
- | [ (?: ^?\. | ^[^\] | [^\^] ) # character classes
- (?: [^]\]+ | \. )* ]
- | ( (?:?[:=!]|?<[=!]|?>)? (?1)?? ) # parenthesis, with recursive content
- | (? (?:R|[+-]?d+) ) # recursive matching
- )
- (?: (?:[?+*]|{d+(?:,d*)?}) [?+]? )? # quantifiers
- | | # alternative
- )* # repeat content
- ) # end first group
- $ # end of string
- /
- /^((?:(?:[^?+*{}()[]\|]+|\.|[(?:^?\.|^[^\]|[^\^])(?:[^]\]+|\.)*]|((?:?[:=!]|?<[=!]|?>)?(?1)??)|(?(?:R|[+-]?d+)))(?:(?:[?+*]|{d+(?:,d*)?})[?+]?)?||)*)$/
- ^ # start of string
- (?:
- (?: [^?+*{}()[]\|]+ # literals and ^, $
- | \. # escaped characters
- | [ (?: ^?\. | ^[^\] | [^\^] ) # character classes
- (?: [^]\]+ | \. )* ]
- | ( (?:?[:=!]
- | ?<[=!]
- | ?>
- | ?<[^Wd]w*>
- | ?'[^Wd]w*'
- )? # opening of group
- (?<N>) # increment counter
- | ) # closing of group
- (?<-N>) # decrement counter
- )
- (?: (?:[?+*]|{d+(?:,d*)?}) [?+]? )? # quantifiers
- | | # alternative
- )* # repeat content
- $ # end of string
- (?(N)(?!)) # fail if counter is non-zero.
- ^(?:(?:[^?+*{}()[]\|]+|\.|[(?:^?\.|^[^\]|[^\^])(?:[^]\]+|\.)*]|((?:?[:=!]|?<[=!]|?>|?<[^Wd]w*>|?'[^Wd]w*')?(?<N>)|)(?<-N>))(?:(?:[?+*]|{d+(?:,d*)?})[?+]?)?||)*$(?(N)(?!))
- SKIP :
- {
- " "
- | "r"
- | "t"
- | "n"
- }
- TOKEN :
- {
- < DIGITO: ["0" - "9"] >
- | < MAYUSCULA: ["A" - "Z"] >
- | < MINUSCULA: ["a" - "z"] >
- | < LAMBDA: "LAMBDA" >
- | < VACIO: "VACIO" >
- }
- IRegularExpression Expression() :
- {
- IRegularExpression r;
- }
- {
- r=Alternation() { return r; }
- }
- // Matchea disyunciones: ER | ER
- IRegularExpression Alternation() :
- {
- IRegularExpression r1 = null, r2 = null;
- }
- {
- r1=Concatenation() ( "|" r2=Alternation() )?
- {
- if (r2 == null) {
- return r1;
- } else {
- return createAlternation(r1,r2);
- }
- }
- }
- // Matchea concatenaciones: ER.ER
- IRegularExpression Concatenation() :
- {
- IRegularExpression r1 = null, r2 = null;
- }
- {
- r1=Repetition() ( "." r2=Repetition() { r1 = createConcatenation(r1,r2); } )*
- { return r1; }
- }
- // Matchea repeticiones: ER*
- IRegularExpression Repetition() :
- {
- IRegularExpression r;
- }
- {
- r=Atom() ( "*" { r = createRepetition(r); } )*
- { return r; }
- }
- // Matchea regex atomicas: (ER), Terminal, Vacio, Lambda
- IRegularExpression Atom() :
- {
- String t;
- IRegularExpression r;
- }
- {
- ( "(" r=Expression() ")" {return r;})
- | t=Terminal() { return createTerminal(t); }
- | <LAMBDA> { return createLambda(); }
- | <VACIO> { return createEmpty(); }
- }
- // Matchea un terminal (digito o minuscula) y devuelve su valor
- String Terminal() :
- {
- Token t;
- }
- {
- ( t=<DIGITO> | t=<MINUSCULA> ) { return t.image; }
- }
- @preg_match($regexToTest, '');
Add Comment
Please, Sign In to add comment