Files
doc-exports/docs/dataartsstudio/umn/dataartsstudio_01_0499.html
chenxiaoxiong c3942cbc2c DataArts UMN 20241028 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
Co-committed-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
2025-07-09 13:09:06 +00:00

29 lines
3.4 KiB
HTML

<a name="dataartsstudio_01_0499"></a><a name="dataartsstudio_01_0499"></a>
<h1 class="topictitle1">StringUtil Embedded Objects</h1>
<div id="body8662426"><p id="dataartsstudio_01_0499__en-us_topic_0132846498_p11157171317917">A StringUtil embedded object provides methods of operating character strings, for example, truncating a substring from a character string.</p>
<p id="dataartsstudio_01_0499__en-us_topic_0132846498_p3433142771011">StringUtil is implemented through org.apache.commons.lang3.StringUtils. For details about how to use the object, see the <a href="https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html" target="_blank" rel="noopener noreferrer">Apache Commons documentation</a>.</p>
<div class="section" id="dataartsstudio_01_0499__en-us_topic_0132846498_section781015577112"><h4 class="sectiontitle">Example 1</h4><p id="dataartsstudio_01_0499__en-us_topic_0132846498_p11951125919113">If variable a is character string No.0010, the substring after <span class="parmvalue" id="dataartsstudio_01_0499__en-us_topic_0132846498_parmvalue1258518202102"><b>.</b></span> is returned. The EL expression is as follows:</p>
<pre class="screen" id="dataartsstudio_01_0499__en-us_topic_0132846498_screen8659135016137">#{StringUtil.substringAfter(a,".")}</pre>
</div>
<div class="section" id="dataartsstudio_01_0499__section1267684110198"><h4 class="sectiontitle">Example 2</h4><p id="dataartsstudio_01_0499__p1846842412617">If variable b is string No,0020, the substring after <span class="parmvalue" id="dataartsstudio_01_0499__parmvalue05907565266"><b>,</b></span> is returned. The EL expression is as follows:</p>
<pre class="screen" id="dataartsstudio_01_0499__screen9980105271914">#{StringUtil.split(b,',')[1]}</pre>
</div>
<div class="section" id="dataartsstudio_01_0499__section152721953323"><h4 class="sectiontitle">Example 3</h4><p id="dataartsstudio_01_0499__p73011047191">If the output of a node is a field, the output result is shown in [["000"]]. The second node references the output of the first node. In this case, the EL expression can be used to split the string result and obtain the field value output by the previous node.</p>
<pre class="screen" id="dataartsstudio_01_0499__screen7655228165518">#{StringUtil.split(StringUtil.split(StringUtil.split(Job.getNodeOutput("Name of the previous node"),"]")[0],"[")[0],"\\"")[0]}</pre>
</div>
<div class="section" id="dataartsstudio_01_0499__section1012572991619"><h4 class="sectiontitle">Example 4</h4><p id="dataartsstudio_01_0499__p16574441181614">If the output of the previous SQL node is [["11"]], the following EL expression can be used to obtain value "11":</p>
<p id="dataartsstudio_01_0499__p1641837161611">#{StringUtil.getDigits(Job.getNodeOutput("nodeName"))}</p>
</div>
<div class="section" id="dataartsstudio_01_0499__section6763152632217"><h4 class="sectiontitle">Example 5</h4><p id="dataartsstudio_01_0499__p173101827234">Returns the digits extracted from a string.</p>
<p id="dataartsstudio_01_0499__p1086616915234">String getDigits(String str)</p>
<p id="dataartsstudio_01_0499__p1556453722219">For example, if str is "1123~45", "112345" is returned; if str is "abc", "" is returned; if str is "12345", "12345" is returned.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dataartsstudio_01_0493.html">EL Expression Reference</a></div>
</div>
</div>