When an XML string is passed to a Java code activity and String.matches regex expression is applied, it fails.

When an XML string is passed to a Java code activity and String.matches regex expression is applied, it fails.

book

Article ID: KB0090455

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Resolution:
Description:
============
When an  XML string is passed to a Java code activity and String.matches regex expression is applied, it fails. The same works fine for other XML strings.


Environment:
===========

BW ALL

Symptoms:
========

The following cods prints false for the supplied XML string

System.err.println(txt.matches("(.*)123456789(.*)"));
System.err.println(txt.matches(".*" ));

XML String ::

'<?xml version="1.0"?> <SearchClaimsRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://services.asurion.com/schemas/SearchClaimsRequest/2.0.0">   <request>     <SearchClaimsByEnrollmentId>       <EnrollmentId>123456789</EnrollmentId>     </SearchClaimsByEnrollmentId>   </request> &lf;</SearchClaimsRequest>'


Cause:
=====
It is caused by the newline feed character “&lf”.


Resolution:
==========
Remove the line feed character before applying the regex.

String out_var_1=in_var_1.replace("\r","").replace("\n","");


References:
==========

Issue/Introduction

When an XML string is passed to a Java code activity and String.matches regex expression is applied, it fails.