I'm working with Python,I need to find next substring of all order-ids using python code.
str = """Delivered-To: example@gmail.com\r\nReceived: by 2002:a05:7022:2496:b0:41:f6c7:a91b with SMTP id cq22csp1730422dlb;\r\n Sat, 2 Jul 2022 06:28:47 -0700 (PDT)\r\nX-Received: by 2002:a0d:e202:0:b0:317:a874:ed5e with SMTP id l2-20020a0de202000000b00317a874ed5emr23336541ywe.16.1656768526947;\r\n Sat, 02 Jul 2022 06:28:46 -0700 (PDT)\r\nARC-Seal: i=1; a=rsa-sha256; t=1656768526; cv=none;\r\n d=google.com; s=arc-20160816;\r\n b=Bg13SC/+O6YTjTWpzhEous8ksXxmiAdmHMXf8vl0wayPdbAQxCOC3R5WLcYLs28Gr6\r\n jljhCngfYqS/deGnQKupI7TJK0OIOgsRTGhWv2TuwAtHUEikt3MOiaVU2haFG/cR2LOA\r\n 4ebPyL/J2hn6Odq9b+hHRHbMDX8tE6fQ+kYAxsXUVK8EYv1HrDvN+EVmeN8atTWraf++\r\n 2fG/FXP+o0HbkGXg2XiQs5PDsjA0E3PUunLnQGJ/XbRBCFiPGfCwHpX3o7Pa+8l2yDAf\r\n 456AGAOKaJVwgoof/oEkAk2cJVShHVrcfaAdTAOB2WoVPxVtmLU8j9fRcRHzwNee4pQX\r\n V5FA==\r\nARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;\r\n h=to:subject:message-id:date:from:mime-version:dkim-signature;\r\n bh=AzAZ1C7TlSF/OObMPEe0rLBlSdgV/qpbwZsWlcKzlnw=;\r\n b=EFPr72+Ffth+A+lV853gas2VFYUAywbGOG2F/w1EbzpVN3HgQUZkK2Tc23muE3Y0FZ\r\n 4YkIGJ5wNlacqn1ZPJZu2esguCx7Xc8quyl586zP4PdtYLUn+Uwdg7U3PqNskYvUtKA4\r\n 7rX8KfHQpLKgPvidvtUtv50WszQNzGjHStvnM3jc0/TzVznPHuGy5JM+30ygUhcT22Sn\r\n Abus2VLuIPWZt6xDzz9fH+RZxtRLZlNo3kLssX5uI37T5QqppKEamqk6WPW7frPM/55S\r\n KtcfjI/z+frS1C5K3CDHofVGrn9I6suNQM/gAnMSBjoF8wekHO76iD6n4RzrifbUFj6c\r\n g0Ww==\r\nARC-Authentication-Results: i=1; mx.google.com;\r\n dkim=pass header.i=@gmail dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com\r\nReturn-Path: <example2@gmail.com>\r\nReceived: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])\r\n by mx.google.com with SMTPS id s127-20020a255e85000000b00663e89b60cbsor10801684ybb.111.2022.07.02.06.28.46\r\n for <yexample@gmail.com>\r\n (Google Transport Security);\r\n Sat, 02 Jul 2022 06:28:46 -0700 (PDT)\r\nReceived-SPF: pass (google.com: domain of vaghasiyadm65@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;\r\nAuthentication-Results: mx.google.com;\r\n dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZkQiOE9S;\r\n spf=pass (google.com: domain of vaghasiyadm65@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=vaghasiyadm65@gmail.com;\r\n dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n d=gmail.com; s=20210112;\r\n h=mime-version:from:date:message-id:subject:to;\r\n bh=AzAZ1C7TlSF/OObMPEe0rLBlSdgV/qpbwZsWlcKzlnw=;\r\n b=ZkQiOE9StPCLPV6aN0tQ/qR0jr3WXSiXrPxz6ES9l4mbG4SAX4kTcFavTWxVTQSpcM\r\n 1Q9+mKsfQc0hSiWT2kJ7GMGLzCA8AYLZGdR6YRmrQtBUzVJLA5cOmPAPEt9Bi/IhDby7\r\n eLyF1LOEZczl4lJpWf2WmJh6788RcwKgcoacAKL4Ic99fs3Jo1AvdJON15q095zhx/UB\r\n XnGGcUWmmGReFq43+1ZD9eucbYLq5wzU37u9uSZ7Ufs86ZYsYLs1q6L741VyyfoBF20p\r\n QjBGMLSqCSgHTg7+jNUlT+ILvzgRbbiRZCojKVN4jdReM7iF7yjGppwbY8iLhzOSWXQj\r\n Jfew==\r\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n d=1e100.net; s=20210112;\r\n h=x-gm-message-state:mime-version:from:date:message-id:subject:to;\r\n bh=AzAZ1C7TlSF/OObMPEe0rLBlSdgV/qpbwZsWlcKzlnw=;\r\n b=qragdi6nn8PakvfOlZDy8mZg5Y7k7cpU/zYTujRt+GbVhquNRl8pBttSyDoWayX/nE\r\n zo/zg708WYFcA0y+JCtRiQbE1tP4eacdgRjrqJVP4aWD2ekhUNV34hFamGHdSLru/kkA\r\n F8LkW/FGUbMI5afo+MsUwOOaBG572+cOFRC60pi5sOzkYMNv8z6/dsULvcmTaJSvx7vQ\r\n TsK17/+B4YbrxjE4ObQWs5sYKTjh3gS4LwAKGMk2iz3urOM/xdiElRW/Devx1hsqValm\r\n iR1T9AmKAXONN/hnsca+XPgN9AF0CvzBM16AgcL/sJxGBTXQydhl/ONjzWEHi/rAHiQP\r\n 3FGQ==\r\nX-Gm-Message-State: AJIora/wEq+AYfVnN5ZkuMS1fy2SFUsnu2fEa6M/g8facCXKwFg75XFI\r\n\tX6kZgkwnI3sZUFr65hyulusVlqMfP8weHYTN+dJ9zo3tXY8=\r\nX-Google-Smtp-Source: AGRyM1sMX8yXEHExf7g/zdvb3g7Jm2YwY7gFCr8f7bDU66Cg8Lvzuwnk07HWkrMNQ690BI3h1ZphPN4TeqZNi6EdkeM=\r\nX-Received: by 2002:a05:6902:11c8:b0:664:6d14:4832 with SMTP id\r\n n8-20020a05690211c800b006646d144832mr19950147ybu.624.1656768526592; Sat, 02\r\n Jul 2022 06:28:46 -0700 (PDT)\r\nMIME-Version: 1.0\r\nFrom: example2 <exampl2@gmail.com>\r\nDate: Sat, 2 Jul 2022 18:58:35 +0530\r\nMessage-ID: <CAJhM7UN+1sQEJ80wRbU+nPzQXO44SkO8MSQjTcW_RmCXSNOpzQ@mail.gmail.com>\r\nSubject: Testing\r\nTo: \"exaple@gmail.com\" <examplee@gmail.com>\r\nContent-Type: multipart/alternative; boundary=\"00000000000080aed005e2d27b4b\"\r\n\r\n--00000000000080aed005e2d27b4b\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\n\r\nTesting mail\r\n\r\n--00000000000080aed005e2d27b4b\r\nContent-Type: text/html; charset=\"UTF-8\"\r\n\r\n<div dir=\"auto\">Dear Seller,Kunal Bapurao Suryvanshi has returned 8 of your packages successfully. Details of the packages delivered: Order ID 403-2972125-1298169 Tracking number 513321566504 Product (s) Women's Velvet Sequence Sleeveless Blouse (ITGFHD-832_Pink_38) (1) Return reason Rejected Order ID 171-9205635-8965901 Tracking number 513318895278 Product (s) Georgette Sharara Suit for Women | Diamond Work Short Kurta with Sharara Plazzo | Kurta Sharara Set with Dupatta (Wine) (1) Return reason C-Returns Secure Returns* Delivered in a tamper proof bag with bag ID sptpr018296434 Order ID 407-6084850-2481910 Tracking number 513315647983 Product (s) Women's Velvet Sleeveless Blouse (ITGFHD-832_Black_38+4" Margin) (1) Return reason C-Returns Order ID 405-0318978-1176378 Tracking number 513312989677 Product (s) Women's Georgette Straight Kurta Sharara Set With Dupatta (DFR-8_Yellow_2XL) (1) Return reason Rejected Order ID 403-7879336-4487536 Tracking number 513318026051 Women's Velvet Sleeveless Blouse (ER-49_Red_Free Size) (1) Return reason C-Returns Order ID 171-5938487-9085769 Tracking number 513553964773 Product (s) Readymade Salwar Suit for Women with Dupatta | Embroidered Neck Kurta and Sharara with Dupatta Set(XXL) Purple (1) Return reason Amazon CS Order ID 408-5127580-8983538 Tracking number 513318975508 Product (s) Women's Velvet heavy Sequence Readymade Sleeveless Blouse (38 Size + 4inch Margin, red) (1) Return reason Rejected Order ID 408-8553883-7805968 Tracking number 513317508899 Product (s) Women's Velvet heavy Sequence Readymade Sleeveless Blouse (38 Size + 4inch Margin, red) (1) Return reason C-Returns </div>\r\n\r\n--00000000000080aed005e2d27b4b--\r\n"""
get=(str[(str.find("id")+3):str.find(" id")])
You could use re.findall
to find the digits after every order-id #
:
import re
str = """order-id #123 order-id #234 order-id #345 order-id #456"""
re.findall(r'order-id #(\d+)', str)
Output:
['123', '234', '345', '456']