Home > Back-end >  The use of the regular expression.
The use of the regular expression.

Time:12-15

Has the following string
 string Str2="x. administrative area==" Beijing \ "| | x. Administrative area==" Shanghai \ "| | x. Administrative area==" \ "in hebei & amp; & X. regional city==\ \ "city" & amp; & X. water-bearing layers of a==\ "shallow " & amp; & X. water-bearing layers of a==\ "deep in the " "; 


Note: the==is a space on both sides;

I now use the regular type
 x \. (. +?)==\ \ "(. +?) \ \ "
can match (space), as shown in figure 1
And with the regular type
 x \. (. +?)==\ \ "(. +?) \ \ "
or
 x \. ([\ s] +)?==\ \ "([\ s] +? \ \ "
will not success;
I'm strange, not to say. Can match the blank space?

CodePudding user response:

=no right answer \ match Spaces, x. (. +?)==. *? \ \ "(. +?) \ \ ", so if there is any space can match
  • Related