Difference between revisions of "Extensions.StringUtil.ReplaceSubString"

From emotive
Jump to navigation Jump to search
Line 1: Line 1:
 
{{DISPLAYTITLE:'''ReplaceSubString '''}}[[Category:StringUtil]]
 
{{DISPLAYTITLE:'''ReplaceSubString '''}}[[Category:StringUtil]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | ReplaceSubString | Replacing strings | [[Term]] | [[Extensions.StringUtil|OTX StringUtil extension]] | [[StringUtil related terms]] | [[Core.Actions.Throw.Exception.OutOfBoundsException|OutOfBoundsException]] | - }}
+
{{ClassificationActivity | ReplaceSubString | Replacing strings | [[Term]] | [[Extensions.StringUtil|OTX StringUtil extension]] | [[Extensions.StringUtil#Terms|StringUtil related terms]] | [[Core.DataTypes.ComplexDataType.OutOfBoundsException|OutOfBoundsException]] | - }}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
StringTerm = ReplaceSubString(StringTerm, StringTerm, IntegerTerm);
+
StringTerm = ReplaceSubString(StringTerm, StringTerm, NumericTerm);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Description ==
 
== Description ==
'''ReplaceSubString''' term replaced the strings with ''replacement'' string, starting at the specified position (''index'') within a strings and returns the result.  
+
'''ReplaceSubString''' term shall yield a new string value which is constructed out of an original string whose contents are overwritten by a replacement string, starting at a given position. If the replacement exceeds the right end of the original string, the length of the resulting string is expanded accordingly.
  
 
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | The replacement string}}
 
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | The replacement string}}
Line 16: Line 16:
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| String | [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1] | The original string}}
+
{{TableRowPropertie2| String | [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1] | Represents the original String.}}
{{TableRowPropertie2| Replacement | [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1] | The string that replaces a portion of the original string starting at the specified position}}
+
{{TableRowPropertie1| Replacement | [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1] | Represents the String value that shall replace the part starting at index of the original String.}}
{{TableRowPropertie1| Index | [[Core.DataTypes.SimpleDataType.Integer|Integer]] | [[Term]] | - | [1] | The zero-based position of the original string, from which starts the replacement}}
+
{{TableRowPropertie2| Index | [[Numeric]] | [[Term]] | - | [1] | The Integer value represents the position in the original String where the replacement starts (the first character in the original String has the index zero). Float values shall be truncated.}}
 
|}
 
|}
  
Line 25: Line 25:
 
String String1;
 
String String1;
  
String1 = ReplaceSubString("emotive company", "COMPANY", 8);
+
/// Flow
 +
 
 +
String1 = StringUtil.ReplaceSubString("emotive company", "COMPANY", 8);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== See also ==
 
== See also ==
 +
<!--[[Extensions.StringUtil.ReplaceSubString|ReplaceSubString]]<br/>-->
 
[[Extensions.StringUtil.MatchToRegularExpression|MatchToRegularExpression]] <br/>
 
[[Extensions.StringUtil.MatchToRegularExpression|MatchToRegularExpression]] <br/>
 
[[Extensions.StringUtil.StringConcatenate|StringConcatenate]] <br/>
 
[[Extensions.StringUtil.StringConcatenate|StringConcatenate]] <br/>

Revision as of 08:20, 3 October 2018

Classification

Name ReplaceSubString
Short Description Replacing strings
Class Term
Extension OTX StringUtil extension
Group StringUtil related terms
Exceptions OutOfBoundsException
Checker Rules -
Standard Compliant Yes

OTL Syntax

StringTerm = ReplaceSubString(StringTerm, StringTerm, NumericTerm);

Description

ReplaceSubString term shall yield a new string value which is constructed out of an original string whose contents are overwritten by a replacement string, starting at a given position. If the replacement exceeds the right end of the original string, the length of the resulting string is expanded accordingly.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
String The replacement string

Properties

Name Data Type Class Default Cardinality Description
String String Term - [1] Represents the original String.
Replacement String Term - [1] Represents the String value that shall replace the part starting at index of the original String.
Index Numeric Term - [1] The Integer value represents the position in the original String where the replacement starts (the first character in the original String has the index zero). Float values shall be truncated.

OTL Examples

String String1;

/// Flow

String1 = StringUtil.ReplaceSubString("emotive company", "COMPANY", 8);

See also

MatchToRegularExpression
StringConcatenate
SubString
LengthOfString
IndexOf
SplitString
ToUpper
ToLower
Encode
Decode