# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"LogNet:..-.ReliableBufferOverflow|(?:Warning: Closing connection. Can't send function[^\r\n]*Reliable buffer overflow)"
test_str = ("# `reliablebufferoverflow_simple` crash\n\n"
"[2024.12.06-12.07.43:682][771]LogStreaming: Display: FlushAsyncLoading(1798): 1 QueuedPackages, 0 AsyncPackages\n"
"[2024.12.06-12.07.43:985][819]LogNet: NMT_CloseReason: (Server Disconnect Reasons) steam.76561198027357835:7777\n"
"[2024.12.06-12.07.43:985][819]LogNet: - ReliableBufferOverflow\n"
"[2024.12.06-12.07.43:985][819]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n"
"[2024.12.06-17.31.59:411][798]LogNet: Warning: Closing connection. Can't send function 'Client_SendSessionSetting' on 'SMLSessionSettingsRemoteCallObject /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.BP_PlayerController_C_2147471387.SMLSessionSettingsRemoteCallObject_2147471320': Reliable buffer overflow. FieldCache->FieldNetIndex: 1 Max 3. Ch MaxPacket: 1024.\n"
"[2024.12.06-17.31.59:411][798]LogNet: UNetConnection::SendCloseReason:\n"
"[2024.12.06-17.31.59:412][798]LogNet: - Result=RPCReliableBufferOverflow, ErrorContext=\"RPCReliableBufferOverflow\"\n\n"
"[2024.12.13-02.01.30:396][970]LogGame: Warning: Failed To Set primary Slot! Invalid index: [30]\n"
"[2024.12.13-02.01.30:398][970]LogNet: NMT_CloseReason: (Server Disconnect Reasons) 80.7.73.10:7777\n"
"[2024.12.13-02.01.30:398][970]LogNet: - ReliableBufferOverflow\n"
"[2024.12.13-02.01.30:398][970]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n"
"[2025.01.20-01.32.38:306][997]AnimBlueprintLog: Warning: SLOTNODE: 'FullBodySlot' in animation instance class Anim_Locker_C already exists. Remove duplicates from the animation graph for this class.\n"
"[2025.01.20-01.32.38:375][997]LogNet: NMT_CloseReason: (Server Disconnect Reasons) steam.76561199070541262:7777\n"
"[2025.01.20-01.32.38:375][997]LogNet: - ReliableBufferOverflow\n"
"[2025.01.20-01.32.38:375][997]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n"
"# More detailed crash (should trigger `reliablebufferoverflow` crash instead of this one!)\n\n"
"[2024.12.03-16.24.15:015][ 81]LogNetPartialBunch: Warning: OutgoingBunches.Num (270) exceeds reliable threashold (8) but this would overflow the reliable buffer! Consider sending less stuff. Channel: [UActorChannel] Actor: FGConveyorChainSubsystem /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.ConveyorChainSubsystem, Role: 3, RemoteRole: 1 [UChannel] ChIndex: 539, Closing: 0 [UNetConnection] RemoteAddr: 197.91.86.165:62243, Name: IpConnection_2147455887, Driver: GameNetDriver FGDSIpNetDriver_2147482083, IsServer: YES, PC: BP_PlayerController_C_2147455555, Owner: BP_PlayerController_C_2147455555, UniqueId: Steam:2 (ForeignId=[Type=6 Handle=1 RepData=[61AC350301001001])\n"
"[2024.12.03-16.24.15:018][ 81]LogNetPartialBunch: Warning: SendBunch: Reliable partial bunch overflows reliable buffer! [UActorChannel] Actor: FGConveyorChainSubsystem /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.ConveyorChainSubsystem, Role: 3, RemoteRole: 1 [UChannel] ChIndex: 539, Closing: 0 [UNetConnection] RemoteAddr: 197.91.86.165:62243, Name: IpConnection_2147455887, Driver: GameNetDriver FGDSIpNetDriver_2147482083, IsServer: YES, PC: BP_PlayerController_C_2147455555, Owner: BP_PlayerController_C_2147455555, UniqueId: Steam:2 (ForeignId=[Type=6 Handle=1 RepData=[61AC350301001001])\n"
"[2024.12.03-16.24.15:019][ 81]LogNetPartialBunch: Warning: Num OutgoingBunches: 270. NumOutRec: 0\n"
"[2024.12.03-16.24.15:019][ 81]LogNet: UNetConnection::SendCloseReason:\n"
"[2024.12.03-16.24.15:019][ 81]LogNet: - Result=ReliableBufferOverflow, ErrorContext=\"ReliableBufferOverflow\"\n"
"[2024.12\n")
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