c# - Parameterized SQL, ORACLE vs SQL Server with regular expression -
oracle , sql server using different prefix parameters in parametrized string.
sql using @p1
ora using :p1
i use in sql @
, in case ora database used :
character should replaces @
.
can please me create regular expression?
here example sql:
update test_table set text = :p1 text = 'jana:klara' or some_value = :value or info = 'two'
similar question , alternative solutions can found here.
you can use pattern search search:
(?<=\w):(?=\w+)
for instance:
string output = regex.replace(input, @"(?<=\w):(?=\w+)", "@");
here's meaning of pattern:
(?<=\w)
-(?<= ... )
syntax declares positive look-behind. in other words, match must preceded contents of look-behind. in case, it's declaring matches must preceded non-word character.:
- matches colon(?=\w+)
-(?= ... )
syntax declares positive look-ahead. in other words, match must followed contents of look-ahead. in case, it's declaring matches must followed 1 or more word-characters.
see online demo.
i can't think of reason why parameter first thing in input string, if possible, changing (?<=^|\w):(?=\w+)
take care of situation too.
Comments
Post a Comment