RegEx help
-
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
-
@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