Text

Example

Convert time in the format "530" or "1407" into text of the type "05:30" or "14:07":


#From#.Length > 3 ? #From#.Substring(0,2) + ":" + #From#.Substring(2,2) : "0" + #From#.Substring(0,1) + ":" + #From#.Substring(1,2)

Functions

For an overview and description of all different kinds of string methods please refer to MSDN


Function/Property

Return value

Description

#name# + #name2#

String

Concatenates strings "name" and "name2".

#name#.Length

Integer

Counts the number of digits in a string.

#name#.StartsWith(s)

Yes/No-Value

Checks if the string begins with a certain string s. Put text in quotation marks, e.g., #name#.StartsWith("AK").

#name#.EndsWith(s)

Yes/No-Value

Checks if the string ends with a certain string s. Put text in quotation marks, e.g., #name#.EndsWith("AK").

#name#.IndexOf(s)

Integer

Returns the zero-based index position of s if that string is found, or -1 if it is not. If s is empty, the return value is 0.

#name#.IndexOf(s, n)

Integer

Return the zero-based index position of s from the start of the current instance if that string is found, or -1 if it is not. If s is empty, the return value is startIndex.

#name#.LastIndexOf(s)

Integer

Return the zero-based starting index position of value if that string is found, or -1 if it is not. If s is empty, the return value is the last index position in this instance.

#name#.Replace(s,f)

String

Replaces all strings s by the string f and returns the result. Example: #name#.Replace("h",":") replaces an h with an :

Handling of special characters: \" as expression for " does not work because the formula operator does not allow an escape sequence.

However, the following formula works:  

#Abt#.Length > 0 ? #Abt#.Substring(1, #Abt#.Length - 1) : "" 

to remove the first character.

#name#.Substring(n)

String

Returns the part of the string that begins at position n. The first character / digit has the position 0.

#name#.Substring(n,m)

String

Returns the part of the string that begins at position n and is max. m characters / digits long. The first character / digit has the position 0.
Example: All characters except the last two:

#name#.Substring(0,#name#.Length-2)

#name#.Contains("text")

True/False value

Checks, if the string "text" occurs.

#name#.ToLower()

String

Converts all letters into lower case letters.

#name#.ToUpper()

String

Converts all letters into upper case letters.

#name#.Trim()

String

Removes all leading and trailing occurrences of a set of characters specified in an array from the current string object.

#A#.Trim(new char[] {':','5','0'}) 

... converts 05:39:51 to 39:51 because 05: stands at the beginning. Nothing is truncated at the end because neither : nor 5 nor 0 stands at the end.

#name#.TrimStart()

String

Removes all leading occurrences of a set of characters specified in an array from the current string object.

#A#.TrimStart(new char[] {':','5','0'}) 

... converts 05:39:51 to 39:51 (05: stands at the beginning and is thus changed)

#name#.TrimEnd()

String

Removes all trailing occurrences of a set of characters specified in an array from the current string object.

 #A#.TrimEnd(new char[] {':','5','0'}) 

... converts 05:39:51 to 05:39:51 (05: stands at the beginning and is thus not changed)

#name#[0]

Integer

Returns the number of the unicode of the zero-based indexed symbol in the string. See also for unicodes UTF-16 https://en.wikipedia.org/wiki/List_of_Unicode_characters.

The following example returns the first symbol:

#name#[0]

Example

Result

Given a column A containing "..."

#A#[0] returns 8230 for the symbol "..." (ellipsis symbol)

Given a column A containing Hugo

#A#[0] returns 72 for the H

'..'.ToString()

Special character

Produces special characters which can be concatenated with other strings by +.
'"'.ToString() returns " as string

System.String.IsNullOrEmpty(#name#)

Boolean

Returns as true/false if a value is missing/empty or if it contains something.

Single special characters

Character

Converts the ASCII-Code into its corresponding character.

(char)34 produces a quotation mark: "
(char)92 produces a backslash: \
more characters under http://ascii.cl/

Line break

Character

(char)10 produces a line break.


Please note: if you need a string just add  +"" to transform. E.g. this function converts line breaks and tabs to \n resp. \t

#Text#.Replace((char)10 + "", (char)92 + "n").Replace((char)9 + "", (char)92 + "t"))

More Examples

Question

Code

Having a string which is delimited by a specified separator, e.g. comma; how can I break a delimited string into substrings?

If the separator is the character ',':

1. part with: 

#Spalte#.Split(new char[]{','})[0] 

2. part with:

#Spalte#.Split(new char[]{','})[1] 

3. part with:

#Spalte#.Split(new char[]{','})[2] 

How can I check if certain characters lie within a certain span of values?

(#TagNr#[0] >= '0' && #TagNr#[0] <= '3'  && #TagNr#[1] >= '0' & #TagNr#[1] <= '9' ? #TagNr# : "0")

The first 8 rows else “0“

(#MADAYKey#.Length > 8 ? #MADAYKey#.Substring(0,#MADAYKey#.Length-8) : "0")

ATTENTION : The first argument in the substring is the beginning (0 is the first character)

Check if a string consists of two characters but delete spaces before.

(#Before#.TrimEnd(' ').Length ==2 ? 1 : 0)
Please note: do not use " but ' because it is a character and not a string.

Adding a number of hours as string in #B# to data #A#

#A#.AddHours(System.Convert.ToInt32(#B#.Substring(0,2))