What is the use of the following statement in python regular expression? -


i new python , need work on existing python script. can explain me meaning of following statement

pgre = re.compile("([^t]+)t([^\.]+)\.[^\s]+\s(\d+\.\d+):\s\[.+\]\s+(\d+)k->(\d+)k\((\d+)k\),\s(\d+\.\d+)\ssecs\]") 

you need consult references exact meanings of each part of regular expression, basic purpose of parse gc logging. each parenthesized part of expression () group matches useful part of gc line.

for example, start of regex ([^t]+)t matches first "t", , grouped part returns text before "t", i.e. date "2013-08-28"

the content of group, [^t]+ means "at least 1 character not t"

patterns in square brackets [] character classes - consult references in comments above details. note input text contains literal square brackets, pattern handles \[ escape sequence - see below.

i think can simplify ([^t]+)t (.+)t, incidentally.

other useful sub-patterns:

  • \s matches whitespace
  • \d matches numeric digits
  • \. \( , \[ match literal periods, parentheses, , square braces, respectively, rather interpreting them special regex characters

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -