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 AABRSTdesired 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
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