Categories

x
Skip Navigation Links
Categories
Skip Navigation Links

Latest Posts

Useful String Manipulation functions in Logic app


In this article, we are going to see a few very useful string manipulation functions that we can use in Logic Apps.

Concat

  • When you want to merge more than one string, you can use this concat() function.
  • Example: concat('Happy','-','New','-','year')
  • logicapp concat
  • Output: Happy-New-year
  • logicapp concat output

Substring

  • When you want to fetch a part of the string value using first index and length of the string, you can use substring() function. Here you need to provide 3 parameters.
    • First parameter takes the string.
    • Second parameter takes the first index
    • Third parameter takes the length.
  • Example: substring('Hello World',0,4)
  • logicapp substring
  • Output: Hello. logicapp substring output
    • Here, it will grab the string from index 0 till 4th Index (Length = 4) that means total 5 characters.
    • You must be thinking if it is 4 characters length, then how it is giving 5 characters in output. The answer is it is including character at position 0 and after that 4 character so total 5.

Slice

  • When you want to fetch a part of the string value using start index and last index, you can use slice() function. Here you need to provide 3 parameters
  • First parameter takes the string.
  • Second parameter takes the first index
  • Third parameter takes the end (last) index.
  • Example: slice('Good Morning',3,10)
  • logicapp slice
  • Output: d Morni logicapp slice output
    • Here, it will take the string between 3rd index and 10th index

Replace

  • When you want to replace a part of the string with another string then you can use replace() function. Here you need to provide 3 parameters. If there are multiple occurrences of the string then also it will update all the matching strings occurances
    • First parameter is an input string
    • Second parameter is the old string that we need to replace
    • Third parameter is the new string to be replace with second parameter.
  • Example: replace('Good afternoon','oo','zz'). We are trying to replace double o with double z.
  • logicapp replace
  • Output: Gzzd Afternzzn
  • logicapp replace output

Guid

  • This is a simple function – guid(), which doesn’t take any argument and generates a globally Unique ID.
  • logicapp GUID

toLower and toUpper

  • toLower() – This function will turn all the characters within the function to lower case.
  • logicapp tolower
  • toUpper() – This function will turn all the characters within the function to upper case.
  • logicapp toupper

indexOf

  • If you want to get the index number/position of a given character or string then you can use the function indexOf(). It takes two parameters.
    • The first parameter is the main string.
    • The second parameter is the string of which we want to get the index number.
  • Example: indexOf('Good Afternoon','oo')
  • logicapp indexof
  • Output: 1
  • logicapp indexof output
    • Here there are two occurrences of ‘oo’ but still it will consider only the first occurrence.

nthIndexOf

  • If you want to know the index number of a string which is repeated nth (1st, 2nd ,…, nth) time, then you can use the function nthIndexOf().There are three parameters in this function.
    • First parameter is the main string.
    • Second parameter is the string that we need to search
    • Third parameter is the number value which indicates the nth place of the second parameter in the first parameter.
  • Example: nthIndexOf('GoodAfternoonandnoon','oo',3)
  • logicapp nthindexof
  • Output: 20
  • logicapp nthindexof output
    • Here, we are targeting the ’oo’ string which is at the third position in the string.

lastIndexOf

  • If you want to get the last index of a value in a string then you can use the function lastIndexOf(). This function takes two arguments
    • First parameter is the main string.
    • Second parameter is the string of which we need to get the last index.
  • Example: lastIndexOf('GoodAfternoonandnoon','oo')
  • Output: 20

startsWith and endsWith

  • startsWith(): If you want to know whether the string is starting with a value or not you can use the function startsWith(). The return value of the function is Boolean (True or False).
  • endsWith(): If you want to know whether the string is ending with a value or not you can use the function startsWith(). The return value of the function is Boolean (True or False).

Split

  • If you want to split the string using a separator, then you can use the function split(). There are two parameters in this function.
    • First parameter is the main string.
    • Second parameter is the separator.
  • Example: split('Goodnoonandafternoon','oo')
  • logicapp split
  • Output: Here , as you can see the string is split into a string array.
  • logicapp split output

Trim

  • When you want to remove leading and trailing spaces from a given string then you can use the function trim(). There is only one parameter and that is string that you want to trim.
  • Example: trim(‘ Good Morning ’)
  • Output: Good Morning

We value your Feedback:

Page URL:

Name:

 

Email:

 
 

Suggestion:

 

© 2023 Code SharePoint