Search code examples
xqueryosb

xquery replace issue in Oracle Service Bus


I'm trying to replace two backslashes with a single one within Oracle Service Bus xquery transformation with the replace function:

let $str := replace($srcStr, "\\\\", "\\"), where $srcStr holds the value "^\\d{1,4}$"

But for some reason this does not work. The result is stil "^\\d{1,4}$"

When I'm calling the same function in e.g. Altova XmlSpy this works fine: replace("^\\d{1,4}$", "\\\\", "\\") results in ^\d{1,4}

Does anybody have an idea why OSB does not match the backslashes in the source string? What could be a workaround?


Solution

  • This is a bug.

    You can write custom regexp to workaround this bug.

    declare function xf:replace_test($e as element()) as xs:string {
        let $str := replace("junk (\)\ junk", ".*\\.*", "\$1")
        return $str
    };
    declare variable $e as element() external; 
    xf:replace_test($e)`