Community
    • Login

    Extract number between two strings

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 525 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Shahir AfifS Offline
      Shahir Afif
      last edited by Shahir Afif

      I am new to notepad++ and have no experience with regular expression so I could really use some help with extracting number between two strings.

      Here is the data I currently have:

      5573300cd8565aad0466cfc69f42350ac4b84|strs1A7FC70016849628742340.pdf|DocType=SAPdocument|sap_file_type=PDF|a_content_type=pdf|sap_object_type=VBRK|sap_object_id=1706090308                    0312314578|sap_archive_id=XO|sap_doc_type=[ZSDOINVOIC]([link url](![notepad++.png](/assets/uploads/files/1687210195436-notepad.png) link url))|system_id=S03|
      
      
      Here is how I would like that data to look (“after” data):
      1706090308                    0312314578
      
      
      I would like to keep the numbers inclusive of the spaces between sap_object_id= and |sap_archive_id
      
      After some googling, I have tried using the following Find/Replace expressions and settings to no avail.
      
      Find What = (?<=object_id).+?(?=sap_archive)
      Replace With =$1
      Search Mode = REGULAR EXPRESSION 
      
      Is there even a possibility to achieve this?  I would greatly appreciate your inputs..
      
      Thank you.
      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT Offline
        Terry R @Shahir Afif
        last edited by

        @Shahir-Afif said in Extract number between two strings:

        Is there even a possibility to achieve this? I would greatly appreciate your inputs…

        It certainly is possible, and you were on the right track.
        Find What:(?-s).+?object_id=(.+?)sap_archive.+
        Replace With:${1}

        Should work for you.

        If you want more information on what it is doing ask.

        Terry

        1 Reply Last reply Reply Quote 4

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors