Community
    • Login

    Help me with Notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.8k 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.
    • kingfisher1111K Offline
      kingfisher1111
      last edited by

      I have a result of SQL query with two colums Name and ROW_ID
      For example here is the output I have pasted in notepad++
      Agreement Expire Workflow 1-TD3H3Y
      Auto CF Asset Pricing Procedure 1-TD3H4U
      Auto Complete 1-TD3HBR
      BIP AttachEntity Report Generation 1-TD3HC8
      BIP Create Report Output 1-TD3HEC
      My requirement is to replace space with _spc and the last row_ID should have double quotes. before the ROW_ID it hsould have = sign. For example it should look like this
      Export_spcAssignment_spcData=“1-7ASH7K”
      The actual nam e is Export Assignment Data 1-7ASH7K

      1 Reply Last reply Reply Quote 0
      • glennfromiowaG Offline
        glennfromiowa
        last edited by

        Curious that you’re not doing that in your SQL query, but I’m assuming you want to do that using Find/Replace in Notepad. Other assumptions: 2) The column divider appears to be a space, but also could be a tab. 3) The words in the Name column will always begin with a letter and never a number (for example, this value would not be present in the Name column: Auto 1CF Asset Pricing Procedure). 4) Only a single space separates the words in the Name column. 5) The ROW_ID column will always begin with a single digit and a hyphen and will never contain spaces. This could be incorrect, but based on your sample data, that seems reasonable.

        So with your output open in Notepad++, open the Replace dialog (Ctrl+H works) and click the bottom radio button Regular expression. Also make sure the Match case checkbox is not checked. You’ll need to do 2 Replace operations. First, paste the next line into the Find what box:
        [ ]([a-z]\S+)
        (?# Space followed by letter followed by non-space chars)
        and paste this into the Replace with box:
        _spc\1
        (?# _spc followed by stuff in parentheses)
        Click the Replace All button and it should replace all spaces, except for the ones in front of the second column, with _spc.
        Then paste this into the Find what box:
        [ \t]+(\d-\S+)
        (?# 1 or more spaces or tabs followed by a digit then a hypen then non-space chars)
        and paste this into the Replace with box:
        =“\1”
        (?# =" followed by stuff in parentheses then by ")
        Click the Replace All button and it should replace all spaces before column 2 with =" and put a " after the value.

        Obviously, check the result to make sure the assumptions were correct and nothing unexpected happened, but that should get you the result from your example.

        1 Reply Last reply Reply Quote 0

        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