Home > other >  About the regular expression, to help everyone
About the regular expression, to help everyone

Time:10-24

 
P='This module provides regular expression matching operations similar to those found in Perl love and'
The pattern=(r 'This \ s \ s] [a zA - Z {1, 3} expression')
M=re the.findall (the pattern, P)
M

Above is my code, return said there was no match to any statements,
I think it is through This period of regular match out (This module provides regular expression)
Because now want A function: from the given all the documents, I want to match to A x x x x x B or B A x x B or B, (A, B, x) are in the word

CodePudding user response:

 
Pattern1=re.com running (' This (. *?) The expression ')
Pattern2=re.com running (r 'This ((\ \ w + s) *) expression')
The pattern=re.com running (' \ w + ')

The above methods all have a problem, you again the mode test set
In fact you can use a whitespace-delimited strings, find the results you want

CodePudding user response:

R 'This \ s \ s] [a zA - Z {1, 3} expression'
in This period of regular[a zA - Z \ s] {1, 3} refers to the individual characters or Spaces in 1 to 3 times, rather than a single word or Spaces appear 1-3 times.
Try this line not line:
"This regex=r \ s (? : \ w + \ s) + expression or This regex=r "\ s (? * expression: \ w + \ s)"
  • Related