Community
    • Login

    RegEx help

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 121 Views
    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.
    • brenda grossB
      brenda gross
      last edited by

      Want a RegEx to add – (two dashes, a comment in SQL) at the beginning of the line if a certain character or word is found in the line. Lines are terminated by \r\n.

      I have a bunch of DB2 SQL that i need to run on MS SQL. If certain non-SQL reserved words or characters are found for now i just want to comment out the statement

      input 3 sql statements. one has the character | and one has the work CONCAT

      SELECT '9' AS PTR, 'RATE POINTER 9 - ' CONCAT '0.0%' AS DESC FROM AABRAT WHERE AZFAO9 = 0  
      SELECT '1', '$'|| REPLACE(LTRIM(EN_COMMARIGHT(INTEGER(DZOL01))),'.00','')  FROM     DDABCR
      SELECT '9' AS PTR FROM AABRST
      

      desired output after two REPLACE. Once for character | and one for work CONCAT. – is added at beginning of line

      --SELECT '9' AS PTR, 'RATE POINTER 9 - ' CONCAT '0.0%' AS DESC FROM AABRAT WHERE AZFAO9 = 0  
      --SELECT '1', '$'|| REPLACE(LTRIM(EN_COMMARIGHT(INTEGER(DZOL01))),'.00','')  FROM     DDABCR
      SELECT '9' AS PTR FROM AABRST
      
      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @brenda gross
        last edited by

        @brenda-gross said in RegEx help:

        one has the character | and one has the work CONCAT

        You could try this using the Replace function:
        Find What:(?-is)^(?=.*(?:CONCAT|\|))(.*)
        Replace With:--\1
        Search mode must be regular expression. You can click on “Replace” to do it singularly, or “Replace All” to change the entire open file.

        I do wonder though that the single character | might be used elsewhere. Hence why I say using the single Replace button so you step through the file and can check each line is correct for change before changing it.

        Terry

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors