import re a = """ UNKNOWN_2(3507), //0xDB3 - listentest.java KNU_BOT_NPC_DESCRIPTION(658522), //0xa0c5a - KnubotNPCDescriptionIIR_c ADD_TEMPLATE(86912780), //0x52e2f0c - AddTemplateIIR_t GRID_DESTINATION_SELECT(104417101), //0x639474d - GridDestinationSelectIIR_t CENTRAL_CONTROLLER_STATE(139685733), //0x8536F65 - CentralControllerStateIIR_t - 2021-01-07 WEATHER_CONTROL(207248749), //0xC5a5d6d - WeatherControlIIR_t PET_TO_MASTER(221781762), //0xd381f02 - PetToMasterIIR_c FLUSH_RDB_CACHES(276329306), //0x1078735a - FlushRDBCachesIIR_c SHOP_SEARCH_RESULT(321942351), //0x1330734f SHOP_SEARCH_REQUEST(341462886), //0x145a4f66 CENTRAL_CONTROLLER_FULL_UPDATE(354759431), //0x15253307 - CentralControllerFullUpdateIIR_t - 2021-01-07 ACCEPT_BS_INVITE(376062814), //0x166a435e - AcceptBSInviteIIR_t ADD_PET(424562550), //0x194e4f76 - AddPetIIR_c SET_POS(425609582), //0x195e496e - SetPosIIR_c CLIENT_REQUEST_CLOSE_GUI(456941901), //0x1b3c614d - ClientRequestCloseGUIIIR_c - 2021-01-07 REFLECT_ATTACK(473583479), //0x1c3a4f77 - ReflectAttackIIR_t SPECIAL_ATTACK_WEAPON(490475292), //0x1d3c0f1c - SpecialAttackWeaponIIR_t ClientContainerAddItem (525164414), //0x1F4D5F7E - ClientContainerAddItemIIR_t - 2021-01-07 MentorInvite (536950654), //0x2001377e - MentorInviteIIR_c Action (541676156), //0x2049527c - ActionIIR_t Script (542066801), //0x204f4871 - ScriptIIR_t FormatFeedback (543902579), //0x206b4b73 - FormatFeedbackIIR_t KnuBotAnswer (553854077), //0x2103247d - KnubotAnswerIIR_c Quest (556550266), //0x212c487a - QuestIIR_t MineFullUpdate (559634040), //0x215b5678 - MineFullUpdateIIR_t LookAt (575816799), //0x2252445f - LookAtIIR_t ShieldAttack (622404726), //0x25192476 - ShieldAttackIIR_t CastNanoSpell (623988077), //0x25314d6d - CastNanoSpellIIR_t ResearchUpdate (624755264), //0x253D0240 - ResearchUpdateIIR - tower related? ResearchUpdate2 (624755276), //0x253d024c FollowTarget (638531185), //0x260f3671 - FollowTargetIIR_c RelocateDynels (642470219), //0x264b514b - RelocateDynelsIIR_t Absorb (642670433), //0x264e5f61 - AbsorbIIR_t Reload (642866785), //0x26515e61 - ReloadIIR_t KnuBotCloseChatWindow (654986338), //0x270a4c62 - KnubotCloseChatWindowIIR_c SimpleCharFullUpdate (656095851), //0x271b3a6b - SimpleCharFullUpdateIIR_t LockableItemFullUpdate (660555345), //0x275f4651 - LockableItemFullUpdateIIR_t - 2021-01-07 StartLogout (673521409), //0x28251f01 - StartLogoutIIR_t Attack (675889264), //0x28494070 - AttackIIR_t TeamMemberInfo (678969928), //0x28784248 - TeamMemberInfoIIR_t CreateQuest (689911323), //0x291F361B - CreateQuestIIR_t - 2021-01-07 FullCharacter (691028809), //0x29304349 - FullCharacterIIR_t LaserTargetList (691213647), //0x2933154f - LaserTagListIIR_t TrapDisarmed (707084127), //0x2a253f5f - TrapDisarmedIIR_t Fov (707345679), //0x2a293d0f - FovIIR_c Stat (724778350), //0x2b333d6e - StatIIR_t QueueUpdate (741279260), //0x2c2f061c - QueueUpdateIIR_t KnuBotRejectedItems (757146631), //0x2d212407 - KnubotRejectedItemsIIR_c PlayerShopFullUpdate (772221560), //0x2e072a78 OrgInfoPacket (774523499), //0x2e2a4a6b - OrgInfoPacketIIR_t N3PlayfieldFullUpdate (806753109), //0x30161355 - n3PlayfieldFullUpdateIIR_t ResearchRequest (823481165), //0x3115534d AreaFormula (824779579), //0x3129233b - AreaFormulaIIR_t InfromPlayer (855716730), //0x3301337a - InfromPlayerIIR_t WaypointPath (858857538), //0x33312042 - WaypointPathIIR_c - 2021-01-07 Mail (859514983), //0x333b2867 - MailIIR_c ApplySpells (875306269), //0x342c1d1d - ApplySpellsIIR_t Bank (876357759), //0x343c287f - BankIIR_t ShopInventory (893341522), //0x353f4f52 TemplateAction (894457412), //0x35505644 - TemplateActionIIR_t Trade (908611438), //0x36284f6e - TradeIIR_t Despawn (911278200), //0x36510078 - n3ToClientQuitIIR_t DoorFullUpdate (911888497), //0x365a5071 - DoorFullUpdateIIR_t CityAdvantages (912151899), //0x365e555b - CityAdvantagesIIR_t HealthDamage (923805036), //0x3710256c - HealthDamageIIR_t PickUp (924019819), //0x37136C6B - ClientGetItemIIR_t - 2021-01-07 FightModeUpdate (924648770), //0x371d0542 - FightModeUpdate_t SetShopName (926823699), //0x373e3513 Buff (959724648), //0x39343c68 - BuffIIR_c KnuBotTrade (974859276), //0x3a1b2c0c - KnubotTradeIIR_c ItemReplaced (975321936), //0x3A223B50 - ItemReplacedIIR_c - 2021-01-07 DropTemplate (975454017), //0x3a243f41 - DropTemplateIIR_t GridSelected (976366154), //0x3a322a4a - GridSelectedIIR_t SimpleItemFullUpdate (990979439), //0x3b11256f - SimpleItemFullUpdateIIR_t KnuBotOpenChatWindow (991112548), //0x3b132d64 - KnubotOpenChatWindowIIR_c WeaponItemFullUpdate (991765096), //0x3b1d2268 - WeaponItemFullUpdateIIR_t SocialActionCmd (992544625), //0x3b290771 - SocialActionCmd_t Raid (993732728), //0x3b3b2878 - RaidIIR_c ShadowLevel (1008609283), //0x3c1e2803 - ShadowLevelIIR_t Clone (1009144185), //0x3c265179 - CloneIIR_t ServerPathPosDebugInfo2 (1031040112), //0x3d746c70 - ServerPathPosDebugInfoIIR_c - 2021-01-07, might be same as ServerPathPosDebugInfo ShopCommission (1029391684), //0x3d5b4544 ServerPathPosDebugInfo (1031040124), //0x3d746c7c - Found new hex and added as ServerPathPosDebugInfo2 2021-01-07 Skill (1042306656), //0x3e205660 - SkillIIR_t ClientRequestDemolish (1058762608), //0x3f1b6f70 - ClientRequestDemolishIIR_c - 2021-01-07 LeaveBattle (1060772116), //0x3f3a1914 - LeaveBattleIIR_t ShopInfo (1079725863), //0x405b4f27 AppearanceUpdate (1096961805), //0x41624f0d - AppearanceUpdateIIR_c N3Teleport (1125743906), //0x43197d22 - n3TeleportIIR_t PerkUpdate (1130328099), //0x435f7023 - PerkUpdateIIR SendScore (1145584442), //0x44483b3a - SendScoreIIR_t Resurrect (1147087371), //0x445f2a0b - ResurrectIIR_t UpdateClientVisual (1158097419), //0x45072a0b - Found new hex and added as UpdateClientVisual2 2021-01-07 UpdateClientVisual2 (1158097453), //0x45072a2d - UpdateClientVisualIIR_t - 2021-01-07, might be same as UpdateClientVisual HouseDemolishStart (1160199946), //0x45273f0a PlaySound (1163733304), //0x455d2938 - PlaySoundIIR_c AttackInfo (1174417174), //0x46002f16 - AttackInfoIIR_t TeamMember (1177627950), //0x46312d2e - TeamMemberIIR_t SpawnMech (1179451402), //0x464d000a - SpawnMechIIR_t QuestFullUpdate (1180319841), //0x465a4061 - QuestFullUpdateIIR_t ChestItemFullUpdate (1180327283), //0x465a5d73 - ChestFullUpdateIIR_t MarketSend (1191915028), //0x470B2E14 - MarketSendIIR_c - 2021-01-07 NanoAttack (1193746750), //0x4727213e DropDynel (1195914803), //0x47483633 - DropDynelIIR_t ContainerAddItem (1196653092), //0x47537a24 - ContainerAddItemIIR_t InventoryUpdated2 (1214149122), //0x485E7202 - InventoryUpdatedIIR_t - 2021-01-07 Visibility (1226974738), //0x49222612 - VisibilityIIR_t KnubotBase (1243422725), //0x4a1d2005 - KnubotBaseIIR_c - 2021-01-07 StopFight (1245782078), //0x4a41203e - StopFightIIR_t BattleOver (1258694937), //0x4b062919 - BattleOverIIR_t InventoryUpdated (1264480770), //0x4b5e7202 - 2021-01-07 Found a dump where it is 0x485E7202 for InventoryUpdated (added that as InventoryUpdated2) n3LocalityUpdate (1280508704), //0x4c530320 - n3LocalityUpdateIIR_t - 2021-01-07 DoorStatusUpdate (1283276859), //0x4c7d403b - DoorStatusUpdateIIR_t TeamInvite2 (1294610747), //0x4d2a313b - TeamInviteIIR_t - 2021-01-07, might be same as TeamInvite TeamInvite (1294613048), //0x4d2a3a38 - 2021-01-07 Found a dump where it is 0x4d2a313b for TeamInvite (added that as TeamInvite2) ShopStatus (1295200295), //0x4d333027 InfoPacket (1295524910), //0x4d38242e - InfoPacketIIR_t SpellList (1296367892), //0x4d450114 - SpellListIIR_t RaidCmd (1314020952), //0x4E525E58 - RaidCmdIIR_c - 2021-01-07 InventoryUpdate (1314089334), //0x4e536976 - InventoryUpdateIIR_t CorpseFullUpdate (1330073093), //0x4f474e05 - CorpseFullUpdateIIR_t Feedback (1347702041), //0x50544d19 - FeedbackIIR_t CharSecSpecAttack (1363747104), //0x51492120 - CharSecSpecAttackIIR_t BankCorpse (1377907744), //0x52213420 - BankCorpseIIR_t GenericCmd (1381132376), //0x52526858 - GenericCmd_t PathMoveCmd (1382441770), //0x5266632a ClientRequestBuild (1392579606), //0x53011416 - ClientRequestBuildIIR_c - 2021-01-07 ArriveAtBs (1410218791), //0x540e3b27 - ArriveAtBsIIR_t CharDCMove (1410404643), //0x54111123 - CharDCMoveIIR_t ClientMoveItemToInventory (1416181567), //0x5469373F - ClientMoveItemToInventoryIIR_t - 2021-01-07 PlayfieldAllTowers (1428293414), //0x55220726 - PlayfieldAllTowersIIR_t KnuBotFinishTrade (1432890148), //0x55682b24 - KnubotFinishTradeIIR_c KnuBotAnswerList (1433423153), //0x55704d31 - KnubotAnswerListIIR_c ClientRequestBuy (1434019330), //0x55796602 - ClientRequestBuyIIR_c - 2021-01-07 StopLogout (1446326328), //0x56353038 - StopLogoutIIR_t CharInPlay (1460412473), //0x570c2039 - CharInPlayIIR_t ShopUpdate (1479942688), //0x58362220 - ShopUpdateIIR_t MechInfo (1482113593), //0x58574239 - MechInfoIIR_t RemovePet (1484007951), //0x58742a0f - RemovePetIIR_c PlayfieldAllCities (1495335206), //0x59210126 - PlayfieldAllCitiesIIR_t TrapItemFullUpdate (1496398120), //0x59313928 - TrapItemFullUpdateIIR_t Inspect (1515741029), //0x5a585f65 - InspectIIR_c PlayfieldTowerUpdateClient (1528694060), //0x5b1e052 - PlayfieldTowerUpdateClientIIR_t ServerPosDebugInfo (1545864196), //0x5c240404 - ServerPosDebugInfoIIR_c QuestAlternative (1547920905), //0x5c436609 - QuestAlternativeIIR_t FullAuto (1548372282), //0x5c4a493a - FullAutoIIR_t ChatCmd (1548900987), //0x5c525a7b MissedAttackInfo (1550142248), //0x5c654b28 - MissedAttackInfoIIR_t KnuBotAppendText (1567642410), //0x5d70532a - KnubotAppendTextIIR_c CharacterAction (1581741936), //0x5e477770 - CharacterActionIIR_t HouseDisappeared (1583046663), //0x5e5b6007 Impulse (1598704748), //0x5f4a4c6c - ImpulseIIR_c PlayfieldAnarchyF (1598757433), //0x5f4b1a39 - PlayfieldAnarchyFIIR_t ChatText (1598768170), //0x5f4b442a - ChatTextIIR_t GameTime (1599226158), //0x5f52412e - GameTimeIIR_t SetWantedDirection (1612717326), //0x60201d0e - SetWantedDirectionIIR_t AoTransportSignal (1651777045), //0x62741e15 - AOTransportSignalIIR_c PetCommand (1664299779), //0x63333303 - 2021-01-07 Found a dump where it is 0x6B333303 for PetCommand (added that as PetCommand2) OrgServer (1683499527), //0x64582a07 - OrgServerIIR_c PetCommand2 (1798517507), //0x6B333303 - PetCommandIIR_c - 2021-01-07 Could be a typo and/or same as PetCommand SetStat (1851741806), //0x6e5f566e - SetStatIIR_t SetName (1934514811), //0x734e5a7b - SetNameIIR_t StopMovingCmd (1949180692), //0x742e2314 - StopMovingCmd_t SpecialAttackInfo (1968115989), //0x754f1115 - SpecialAttackInfoIIR_t GiveQuestToMember (1998784807), //0x77230927 - GiveQuestToMembersIIR_t KnuBotStartTrade (2019835933), //0x7864401d - KnubotStartTradeIIR_c GfxTrigger (2049057282), //0x7a222202 - GfxTriggerIIR_t ACGQuest (2053533449), //0x7a666f09 - ACGQuestIIR_t - 2021-01-07 ShopItemPrice (2113941807), //0x7e00312f NewLevel (2134923798), //0x7f405a16 - NewLevelIIR_t OrgClient (2135634184), //0x7f4b3108 - OrgClientIIR_c VendingMachineFullUpdate (2136230149); //0x7f544905 - VendingMachineFullUpdateIIR_t """ d = [x.strip() for x in a.split("\n")] print(d) for y in d: x = y.split("(") if m := re.sub( r"([A-Z]+)", r" \1", x[0]).split(): print("_".join([xx.upper() for xx in m])+"("+x[1])