# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^Points\b.*(?:\n.+)+"
test_str = ("Data-Information\n"
"Name: Polymer A\n"
"Sample: Sunday till Monday\n"
"User: SUD\n"
"Count Segments: 5\n"
"Application: RHEOSTAR\n"
"Tool: CP\n"
"Date/Time: 24.10.2021; 13:37\n"
"System: CP25\n\n"
"Constants:\n"
"- Csr [min/s]: 2,5421\n"
"- Css [Pa/mNm]: 2,54679\n\n"
"Section: 1\n"
"Number measuring points: 0\n\n"
"Time limit: 2 measuring points, drop\n"
" Duration 30 s\n"
"Measurement profile:\n"
" Temperature T[-1] = 25 °C\n\n"
"Section: 2\n"
"Number measuring points: 30\n\n"
"Time limit: 30 measuring points\n"
" Duration 2 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"1 62 10,93 100 1.090 4,45 TGC,Dy_\n"
"2 64 11,05 100 1.100 4,5 TGC,Dy_\n"
"3 66 11,07 100 1.110 4,51 TGC,Dy_\n"
"4 68 11,05 100 1.100 4,5 TGC,Dy_\n"
"5 70 10,99 100 1.100 4,47 TGC,Dy_\n"
"6 72 10,92 100 1.090 4,44 TGC,Dy_\n\n\n"
"Section: 3\n"
"Number measuring points: 0\n\n"
"Time limit: 2 measuring points, drop\n"
" Duration 60 s\n\n"
"Section: 4\n"
"Number measuring points: 30\n\n"
"Time limit: 30 measuring points\n"
" Duration 2 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"*** 1 *** 242 -6,334E+6 -0,0000115 72,7 0,296 TGC,Dy_\n"
"2 244 63,94 10,3 661 2,69 TGC,Dy_\n"
"3 246 35,56 20,7 736 2,99 TGC,Dy_\n"
"4 248 25,25 31 784 3,19 TGC,Dy_\n"
"5 250 19,82 41,4 820 3,34 TGC,Dy_\n\n\n"
"Section: 5\n"
"Number measuring points: 300\n\n"
"Time limit: 300 measuring points\n"
" Duration 1 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"1 301 4,142 300 1.240 5,06 TGC,Dy_\n"
"2 302 4,139 300 1.240 5,05 TGC,Dy_\n"
"3 303 4,138 300 1.240 5,05 TGC,Dy_\n"
"4 304 4,141 300 1.240 5,06 TGC,Dy_\n"
"5 305 4,156 300 1.250 5,07 TGC,Dy_\n"
"6 306 4,153 300 1.250 5,07 TGC,Dy_\n\n\n"
"Data-Information\n"
"Name: Polymer B\n"
"Sample: Monday till Tuesday\n"
"User: SUD\n"
"Count Segments: 5\n"
"Application: RHEOSTAR\n"
"Tool: CP\n"
"Date/Time: 24.10.2021; 13:37\n"
"System: CP25\n\n"
"Constants:\n"
"- Csr [min/s]: 2,5421\n"
"- Css [Pa/mNm]: 2,54679\n\n"
"Section: 1\n"
"Number measuring points: 0\n\n"
"Time limit: 2 measuring points, drop\n"
" Duration 30 s\n"
"Measurement profile:\n"
" Temperature T[-1] = 25 °C\n\n"
"Section: 2\n"
"Number measuring points: 30\n\n"
"Time limit: 30 measuring points\n"
" Duration 2 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"1 62 10,93 100 1.090 4,45 TGC,Dy_\n"
"2 64 11,05 100 1.100 4,5 TGC,Dy_\n"
"3 66 11,07 100 1.110 4,51 TGC,Dy_\n"
"4 68 11,05 100 1.100 4,5 TGC,Dy_\n"
"5 70 10,99 100 1.100 4,47 TGC,Dy_\n"
"6 72 10,92 100 1.090 4,44 TGC,Dy_\n\n\n"
"Section: 3\n"
"Number measuring points: 0\n\n"
"Time limit: 2 measuring points, drop\n"
" Duration 60 s\n\n"
"Section: 4\n"
"Number measuring points: 30\n\n"
"Time limit: 30 measuring points\n"
" Duration 2 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"*** 1 *** 242 -6,334E+6 -0,0000115 72,7 0,296 TGC,Dy_\n"
"2 244 63,94 10,3 661 2,69 TGC,Dy_\n"
"3 246 35,56 20,7 736 2,99 TGC,Dy_\n"
"4 248 25,25 31 784 3,19 TGC,Dy_\n"
"5 250 19,82 41,4 820 3,34 TGC,Dy_\n\n\n"
"Section: 5\n"
"Number measuring points: 300\n\n"
"Time limit: 300 measuring points\n"
" Duration 1 s\n\n"
"Points Time Viscosity Shear rate Shear stress Momentum Status\n"
" [s] [Pa·s] [1/s] [Pa] [mNm] []\n"
"1 301 4,142 300 1.240 5,06 TGC,Dy_\n"
"2 302 4,139 300 1.240 5,05 TGC,Dy_\n"
"3 303 4,138 300 1.240 5,05 TGC,Dy_\n"
"4 304 4,141 300 1.240 5,06 TGC,Dy_\n"
"5 305 4,156 300 1.250 5,07 TGC,Dy_\n"
"6 306 4,153 300 1.250 5,07 TGC,Dy_")
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