Introduction

Syntax

Program Help

Examples

Download

Match Tool 2.1

Match Tool 3.0

 

DEELX Extended Syntax: Zero-width Assertion

Return: Content | Prev: Non-capture group | Next: Independent expression


Zero-width Assertion

More convenient character boundary condition, and it will not match any character itself.


Remarks

Zero-width assertions have two directions, forward and backward:

Expression

Direction

Description

(?=xxx)

Forward (Right)

Look ahead, test if the pattern matches right side

(?!xxx)

Look ahead negative, test if the pattern does not match

(?<=xxx)

Backward (Left)

Look behind, test if the pattern matches left side

(?<!xxx)

Look behind negative, test if the pattern does not match

In DEELX, the sub-expression within the "forward assertion" is always LEFT to RIGHT match mode, and the sub-expression within the "backward assertion" is always RIGHT to LEFT match mode.

"Forward assertion" is mostly the same in different engines.

But as to "backward assertion", they are different in Perl, Java, GRETA and DEELX in details:

Engine

Description

Example

Perl

Works only for fixed-width lookbehind.

(?<=\t)print

Java

Non-fixed width, but maximum needed.

(?<=\{\s{0,100})print

GRETA

Non-fixed width, but the negative has some bugs.

(?<=\{\s*)print

In DEELX:

DEELX uses RIGHTTOLEFT mode to match "Backward assertion". The backward assertion has the same logic as lookahead assertion, except the direction. So, in DEELX, the backward assertion works for non-fixed width lookbehind.

For example, in DEELX:

Text

Expression

Result

{print}

(?<!\{\s*)print

Fail

(?<=\{\s*)print

Success

 

 

RegExLab.com © 2005 - All Rights Reserved