Regular Expressions 101

Community Patterns

Replace quotas in ODI code excluding Beabshell substitutions

1

Regular Expression
PCRE (PHP <7.3)

/
"(?=(?:(?:[^<](?!%>))*(?:<%[^%]+%>)(?:[^<](?!%>))*)*$)
/
g

Description

This example helps the ODI developer to generate code. If some parts of the dynamic code arrive in KM via Option, it is difficult to process it in Beanshell. And more so it is difficult if the code part contains Beanshell-substitution.

This example shows how to replace e.g. quotes in the code and do not break down Beanshell-substitutions.

Select "Field1" from <%=odiRef.getSchemaName("SCHEMA1")%>."Table1" Will turn into Select ##Field1## from <%=odiRef.getSchemaName("SCHEMA1")%>.##Table1## and then, only in this form it could be assigned to Beanshell variable.

E.g. <% String stmt = odiRef.getOption("Option1").replaceAll("[\r\n]"," ").replaceAll("this magic regexp","##") %>

Submitted by Naeel Maqsudov - 5 years ago