# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^(.*?):(\d+):(\d*):?\s+(?:fatal\s+)?(warning|error):\s+(.*)$"
test_str = ("[ 38%] Built target embedded_epjson_source\n"
"[ 38%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUEN673.cpp.o\n"
"[ 38%] Building CXX object third_party/libtk205/src/CMakeFiles/libtk205.dir/rs0002_factory.cpp.o\n"
"[ 38%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUGapDeflection.cpp.o\n"
"[ 38%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUGapLayer.cpp.o\n"
"[ 38%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUSolidDeflection.cpp.o\n"
"In file included from /usr/include/c++/13/bits/hashtable_policy.h:36,\n"
" from /usr/include/c++/13/bits/hashtable.h:35,\n"
" from /usr/include/c++/13/bits/unordered_map.h:33,\n"
" from /usr/include/c++/13/unordered_map:41,\n"
" from /home/runner/work/EnergyPlus/EnergyPlus/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp:55,\n"
" from /home/runner/work/EnergyPlus/EnergyPlus/src/EnergyPlus/AirflowNetwork/src/Solver.cpp:48:\n"
"In static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = char; _Up = char; bool _IsMove = false]’,\n"
" inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,\n"
" inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,\n"
" inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31,\n"
" inlined from ‘_OI std::copy(_II, _II, _OI) [with _II = char*; _OI = char*]’ at /usr/include/c++/13/bits/stl_algobase.h:633:7,\n"
" inlined from ‘static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = char*; _ForwardIterator = char*]’ at /usr/include/c++/13/bits/stl_uninitialized.h:147:27,\n"
" inlined from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = char*; _ForwardIterator = char*]’ at /usr/include/c++/13/bits/stl_uninitialized.h:185:15,\n"
" inlined from ‘void fmt::v8::basic_memory_buffer<T, SIZE, Allocator>::grow(size_t) [with T = char; long unsigned int SIZE = 500; Allocator = std::allocator<char>]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/format.h:754:26,\n"
" inlined from ‘void fmt::v8::detail::buffer<T>::try_reserve(size_t) [with T = char]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/core.h:842:39,\n"
" inlined from ‘void fmt::v8::detail::buffer<T>::push_back(const T&) [with T = char]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/core.h:846:16,\n"
" inlined from ‘std::string_view fmt::v8::formatter<{anonymous}::DoubleWrapper>::spec_builder()’ at /home/runner/work/EnergyPlus/EnergyPlus/src/EnergyPlus/IOFiles.hh:144:25:\n"
"/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ writing between 2 and 9223372036854775807 bytes into a region of size 1 overflows the destination [-Wstringop-overflow=]\n"
" 437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);\n"
" | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
"In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/c++allocator.h:33,\n"
" from /usr/include/c++/13/bits/allocator.h:46,\n"
" from /usr/include/c++/13/bits/alloc_traits.h:39,\n"
" from /usr/include/c++/13/ext/alloc_traits.h:34,\n"
" from /usr/include/c++/13/bits/hashtable_policy.h:39:\n"
"In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = char]’,\n"
" inlined from ‘static _Tp* std::allocator_traits<std::allocator<_Tp1> >::allocate(allocator_type&, size_type) [with _Tp = char]’ at /usr/include/c++/13/bits/alloc_traits.h:482:28,\n"
" inlined from ‘void fmt::v8::basic_memory_buffer<T, SIZE, Allocator>::grow(size_t) [with T = char; long unsigned int SIZE = 500; Allocator = std::allocator<char>]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/format.h:752:49,\n"
" inlined from ‘void fmt::v8::detail::buffer<T>::try_reserve(size_t) [with T = char]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/core.h:842:39,\n"
" inlined from ‘void fmt::v8::detail::buffer<T>::push_back(const T&) [with T = char]’ at /home/runner/work/EnergyPlus/EnergyPlus/third_party/fmt-8.0.1/include/fmt/core.h:846:16,\n"
" inlined from ‘std::string_view fmt::v8::formatter<{anonymous}::DoubleWrapper>::spec_builder()’ at /home/runner/work/EnergyPlus/EnergyPlus/src/EnergyPlus/IOFiles.hh:144:25:\n"
"/usr/include/c++/13/bits/new_allocator.h:151:55: note: destination object of size 1 allocated by ‘operator new’\n"
" 151 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));\n"
" | ^\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUSolidLayer.cpp.o\n"
"[ 39%] Building CXX object src/EnergyPlus/AirflowNetwork/CMakeFiles/airflownetworklib.dir/src/Elements.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IGUVentilatedGapLayer.cpp.o\n"
"[ 39%] Building CXX object third_party/libtk205/src/CMakeFiles/libtk205.dir/rs0003.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/IndoorEnvironment.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/LayerInterfaces.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/Layers.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/NonLinearSolver.cpp.o\n"
"[ 39%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/NusseltNumber.cpp.o\n"
"[ 39%] Building CXX object third_party/libtk205/src/CMakeFiles/libtk205.dir/rs0003_factory.cpp.o\n"
"[ 40%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/OutdoorEnvironment.cpp.o\n"
"[ 40%] Building CXX object src/EnergyPlus/CMakeFiles/energyplusparser.dir/DataStringGlobals.cc.o\n"
"[ 40%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/PermeabilityFactor.cpp.o\n"
"[ 40%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/SimpleIGU.cpp.o\n"
"[ 40%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/SingleSystem.cpp.o\n"
"[ 41%] Building CXX object src/EnergyPlus/CMakeFiles/energyplusparser.dir/FileSystem.cc.o\n"
"[ 41%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/SupportPillar.cpp.o\n"
"[ 41%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/Surface.cpp.o\n"
"[ 42%] Building CXX object third_party/Windows-CalcEngine/CMakeFiles/Windows-CalcEngine.dir/src/Tarcog/src/System.cpp.o\n"
"[ 43%] Building CXX object third_party/libtk205/src/CMakeFiles/libtk205.dir/rs0004.cpp.o")
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