Regular - zero models assertion

Outline:

  1. grammar
  2. Real

First, grammar

  1. (?<=pattern)pattern
  2. (?<!pattern) pattern
  3. pattern(?=pattern)
  4. pattern(?!pattern)

There are four models of zero assertion syntax, all consists of two parts consisting of regular, matching the red part of the real content.

 

Second, combat

Text: Youth do not know worry about the taste, as Fu poetry that worry .

This paper has two unhappy words, you can take advantage of zero models assertion, find one of them according to the rules.

  • test1: find does not know the back of the melancholy words

The first method directly to not know behind melancholy words

(? <= Do not know) worry

The second method, to find non- keung said the back of the unhappy word

(? <! Keung said) worry

 

  • test2: find the taste of the previous unhappy

The first method, directly to the taste of the previous unhappy

Worry (? = Taste)

The second method, to find non . Front worry

worry(?!.)

 

Guess you like

Origin www.cnblogs.com/liuboyuan/p/11570631.html