Home > other >  A regular expression to extract the specified string
A regular expression to extract the specified string

Time:09-30

I have a web page code, part are as follows:







The Last KH: 7.10
PH: 8.41 & lt; Br> CKI=240 NT relationship: 147
Min W: 191 AutoMode: 1

P: STANDBY SYS: READY & lt; Br> L.T ime: 02/06 14:52:00 C.T ime: 02/06 16:27:14




I need to extract the Last KH behind the Numbers, and the Numbers behind the PH, could you tell me how to write code, find didn't find the entire network to extract keywords specified content of the tutorial, the regular expression is so hard...

CodePudding user response:

 
S="'







The Last KH: 7.10
PH: 8.41 & lt; Br> CKI=240 NT relationship: 147
Min W: 191 AutoMode: 1

P: STANDBY SYS: READY & lt; Br> L.T ime: 02/06 14:52:00 C.T ime: 02/06 16:27:14



"'

The import re
M=re match (r '. * Last KH:. * (\ d + \ \ d +). The pH: *. * (\ d + \ \ d +). * ', s, flags.=re DOTALL)
Print (m.g roup (1))
Print (m.g roup (2))
  • Related