Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"""
(?P<HEADER> (?: (^|\n) ^[^\t\n][^\n]* ){3,}) # header of 3+ none-indented lines | (?P<HANDLE> \n \n ^Handle \s+ (?P<_hex> 0x[0-9a-fA-F]+) \s*, \s* DMI \s+ type \s+ (?P<_dmi> \d+ ) \s*, \s* (?P<_bytes> \d+ ) \s+ bytes \s*? ^(?P<_hname> \w [^\n]*) $ ) | (?P<KEYVAL> ^ \t (?P<_key> \w [^\n\t:]* ) [ ]* : [ ]+ (?P<_val> [^\n\t]+ ) $ ) | (?P<LIST> ^ \t (?P<_lname> \w [^\n\t:]* ) [ ]* : [^\n]* (?P<_lvals> (?: \n \t\t (?P<_lval> \S [^\n]* ) ) * ) $ ) | (?P<_WHOOPS_> \S[^\n]* )
"""
gmx

Description

Used to match all parts of output from dmidecode.

Submitted by Paddy3118 - 2 years ago