# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^\d+(?:\.\d+)* .*(?:\r?\n(?!\d+(?:\.\d+)* ).*)*"
test_str = ("I.S. EN 60601-1:2006&A1:2013&AC:2014&A12:2014\n\n"
"60601-1 © IEC:2005 \n"
"60601-1 © IEC:2005\n\n"
"– 337 – \n"
"– 169 –\n\n"
"12.4.5.4 Other ME EQUIPMENT producing diagnostic or therapeutic radiation \n"
"When applicable, the MANUFACTURER shall address in the RISK MANAGEMENT PROCESS the \n"
"RISKS associated with ME EQUIPMENT producing diagnostic or therapeutic radiation other than \n"
"for diagnostic X-rays and radiotherapy (see 12.4.5.2 and 12.4.5.3). \n\n"
"Compliance is checked by inspection of the RISK MANAGEMENT FILE.\n\n"
"12.4.6 Diagnostic or therapeutic acoustic pressure \n"
"When applicable, the MANUFACTURER shall address in the RISK MANAGEMENT PROCESS the \n"
"RISKS associated with diagnostic or therapeutic acoustic pressure. \n\n"
"Compliance is checked by inspection of the RISK MANAGEMENT FILE.\n\n"
"13 * HAZARDOUS SITUATIONS and fault conditions\n\n"
"13.1 Specific HAZARDOUS SITUATIONS\n\n"
"* General \n\n"
"13.1.1 \n"
"When applying the SINGLE FAULT CONDITIONS as described in 4.7 and listed in 13.2, one at a \n"
"time, none of the HAZARDOUS SITUATIONS in 13.1.2 to 13.1.4 (inclusive) shall occur in the \n"
"ME EQUIPMENT.\n\n"
"The failure of any one component at a time, which could result in a HAZARDOUS SITUATION, is \n"
"described in 4.7. \n\n"
"* Emissions, deformation of ENCLOSURE or exceeding maximum temperature \n\n"
"13.1.2 \n"
"The following HAZARDOUS SITUATIONS shall not occur: \n"
"– emission of flames, molten metal, poisonous or ignitable substance in hazardous \n\n"
"quantities; \n\n"
"– deformation of ENCLOSURES to such an extent that compliance with 15.3.1 is impaired; \n"
"– \n\n"
"temperatures of APPLIED PARTS exceeding the allowed values identified in Table 24 when \n"
"measured as described in 11.1.3; \n"
"temperatures of ME EQUIPMENT parts that are not APPLIED PARTS but are likely to be \n"
"touched, exceeding the allowable values in Table 23 when measured and adjusted as \n"
"described in 11.1.3; \n\n"
"– \n\n"
"– exceeding the allowable values for “other components and materials” identified in Table 22 \n"
"times 1,5 minus 12,5 °C. Limits for windings are found in Table 26, Table 27 and Table 31. \n"
"In all other cases, the allowable values of Table 22 apply. \n\n"
"Temperatures shall be measured using the method described in 11.1.3. \n\n"
"The SINGLE FAULT CONDITIONS in 4.7, 8.1 b), 8.7.2 and 13.2.2, with regard to the emission of \n"
"flames, molten metal or ignitable substances, shall not be applied to parts and components \n"
"where: \n"
"– The construction or the supply circuit limits the power dissipation in SINGLE FAULT \n\n"
"CONDITION to less than 15 W or the energy dissipation to less than 900 J. ")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html