Showing results for 
Search instead for 
Did you mean: 
New Member

Inserting delimiter in string



I have a situation where I am pulling a string value from a document processing power app. When I get the string in power automate it outputs as a block of sentences see example below:


"This is the first sentence.This is the second sentence.This is the third."


I need to be able to put a delimiter into the string after every "." If it is followed by an uppercase letter. The reason for this is that the sentences are  put into an array later in the flow.


My issue is sometimes there is "." Or capital letters in the sentence so I need to be very specific and only insert a delimiter if the period is followed by an upper case letter as this always indicates the end of a scentence in the string.


Is there any way to achieve this with an expression? Any help is greatly appreciated!




Hi @Anonymous22 ,

Do you want:

1.Split blocks of sentences with periods.

  1. If the first letter of the sentence is capitalized, add a delimiter to the sentence.

Here is a test for you reference:

I enter text by [Manually trigger a flow]

Note: [<br>is a delimiter.]




Here is result:



Best Regards

Cheng Feng

Hi @v-chengfen-msft,

Thank you for that. One problem I am facing is some of the sentences contain thing like "e.g." or "ect.)."

In the string seeing as there is no spaces between the sentences is there a way to adjust the above to only insert the delimiter where the end of the sentence is followed by a capital letter?

Ex: "This is the first sentence ect.).This is the second sentence."

Community Champion
Community Champion

Whenever I see something like this I think of Regular Expressions (RegEx).


We don't have anything natively available to use in Power Automate with regards to RegEx, but we can leverage Excel Office Scripts which is a really powerful way to extend what we can do in Power Automate (without having to purchase third-party solutions, etc.).


I generally have an Excel file stored in a location accessible to everyone in the company (read-only) where I add useful scripts that people can use. For this example, I created one to substitute text using the Replace method.


I've got a Library with an Excel file called Scripts.xlsx and have created an Office Script called regexReplace.





To create a script, click on Automate > New Script.


The code for the regexReplace script is below:

function main(
  workbook: ExcelScript.Workbook,
  searchString: string,
  regexPattern: string,
  regexFlags: string,
  replaceString?: string): string {
  if (typeof (replaceString) === 'undefined') {
    replaceString = '';

  let re = new RegExp(regexPattern, regexFlags)

  return searchString.replace(re, replaceString)


You can then use this script in your Power Automate by using the Excel Online (Business) action Run script.


The full flow is below. I'll go into each of the actions.



Initialize variable just adds your sample text for the example into a string variable called input.



In this example I'm using the following text:

This is the first sentence ect.).This is the second sentence.And the third.


The Run script Substitute is the Excel Online (Business) action called Run script. This calls the Office Script passing in the relevant parameters including:

  • Script - the script within your Excel file.
  • searchString - the string you want to search.
  • regexPattern - the pattern you want to match on.
  • regexFlags - what regex flags you want to use.
  • replaceString - what you want to replace the matches with.

In our case we pass in the variable input for the searchString.


For the regexPattern we use ([.])([A-Z]) which has two groups. The first one will match on a single period, and the second one will match on a single uppercase character. So, it would match on .T or .H for example. We have the groupings () so that we can extract out the actual values found and substitute them back in with addition characters we want. In my example I insert two ++ between the . and the uppercase character so I can split on ++ later. You can add whatever you want, but I went with ++ since I'm sure we wouldn't see this in any of your sentences.


I've just used g for the flags, so it doesn't stop on the first match.


And finally, we build up the result which is the value returned from the first group - a single period, the characters ++, then the value returned from the second group - the uppercase character. .++T or .++H for example.





The output for this example would be:

"This is the first sentence ect.).++This is the second sentence.++And the third."


Lastly, I just use a Compose to split the result on ++ so we get each sentence as a new item in our array.

split(outputs('Run_script_Substitute')?['body/result'], '++')



Outputs from the flow run below:




If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.

Helpful resources

Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (1,662)