{"id":958,"date":"2025-10-02T16:25:40","date_gmt":"2025-10-02T16:25:40","guid":{"rendered":"https:\/\/www.techpolaju.com\/blog\/?p=958"},"modified":"2025-10-02T16:36:24","modified_gmt":"2025-10-02T16:36:24","slug":"substring-function","status":"publish","type":"post","link":"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/","title":{"rendered":"Ultimate Power Automate Substring Function Explained &#8211; 6 Powerful Examples"},"content":{"rendered":"\n<p>If you have ever needed to extract part of a string in your flow, this tutorial will guide you through the Ultimate Power Automate Substring Function Explained with step-by-step examples. Whether you\u2019re building automation for email parsing, document naming, or text extraction, the substring function will quickly become one of your most useful tools in Power Automate.<\/p>\n\n\n\n<p>In this tutorial, we\u2019ll explore 6 variations of substring so you can master text manipulation in your flows.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%A7%B0_Prerequisites\" >\ud83e\uddf0 Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%9A%80_Step-by-Step_Examples\" >\ud83d\ude80 Step-by-Step Examples<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_1_Substring_by_Start_Index_Length\" >\ud83d\udd39 1. Substring by Start Index + Length<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_2_Substring_by_Start_Index_End_Index\" >\ud83d\udd39 2. Substring by Start Index + End Index<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_3_Substring_by_Start_Marker_End_Marker\" >\ud83d\udd39 3. Substring by Start Marker + End Marker<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_4_Substring_from_Start_Index_Until_End\" >\ud83d\udd39 4. Substring from Start Index Until End<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_5_Substring_from_Start_to_Midpoint\" >\ud83d\udd39 5. Substring from Start to Midpoint<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%94%B9_6_Substring_from_Midpoint_to_End\" >\ud83d\udd39 6. Substring from Midpoint to End<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%F0%9F%93%88_Why_This_Matters\" >\ud83d\udcc8 Why This Matters<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#%E2%9C%85_Wrapping_Up\" >\u2705 Wrapping Up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/#_%F0%9F%9A%80_Bonus_tutorials\" >&nbsp;\ud83d\ude80 Bonus tutorials:<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%A7%B0_Prerequisites\"><\/span>\ud83e\uddf0 Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before we dive into the examples, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Microsoft 365 account with access to <a href=\"https:\/\/make.powerautomate.com\/\" target=\"_blank\" rel=\"noopener\">Power Automate<\/a><\/li>\n\n\n\n<li>Basic knowledge of creating a flow<\/li>\n\n\n\n<li>Familiarity with expressions in Power Automate<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-1024x573.png\" alt=\"Substring Function Explained\" class=\"wp-image-972\" srcset=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-1024x573.png 1024w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-300x168.png 300w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-768x430.png 768w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image.png 1305w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%9A%80_Step-by-Step_Examples\"><\/span>\ud83d\ude80 Step-by-Step Examples<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For our examples, we\u2019ll use the same input string stored in a variable:<\/p>\n\n\n\n<p><strong>Input Text:<\/strong><br><code>The quick brown fox jumps over the lazy dog<\/code><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-3-1024x370.png\" alt=\"\" class=\"wp-image-963\" srcset=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-3-1024x370.png 1024w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-3-300x109.png 300w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-3-768x278.png 768w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-3.png 1078w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>\ud83e\udd8a <strong>Fun Fact:<\/strong><br>\u201cThe quick brown fox jumps over the lazy dog\u201d is a <strong>pangram<\/strong> \u2014 a sentence that contains <strong>all 26 letters of the English alphabet<\/strong> at least once. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_1_Substring_by_Start_Index_Length\"><\/span>\ud83d\udd39 1. Substring by Start Index + Length<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Extract a portion of text by providing a starting index and length.<br>The index represents the position of the character where you want the substring to start, and from that point it will extract text based on the specified length. <\/p>\n\n\n\n<p>In the expression below, we are using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Text<\/strong>: coming from the variable <code>variables('Input Text')<\/code><\/li>\n\n\n\n<li><strong>Index<\/strong>: set to <code>4<\/code> (the starting position of the substring)<\/li>\n\n\n\n<li><strong>Length<\/strong>: set to <code>5<\/code> (the number of characters to extract)<\/li>\n<\/ul>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'), 4, 5)<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><br><code>quick<\/code><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"391\" src=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-4-1024x391.png\" alt=\"\" class=\"wp-image-964\" srcset=\"https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-4-1024x391.png 1024w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-4-300x115.png 300w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-4-768x293.png 768w, https:\/\/www.techpolaju.com\/blog\/wp-content\/uploads\/2025\/10\/image-4.png 1053w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_2_Substring_by_Start_Index_End_Index\"><\/span>\ud83d\udd39 2. Substring by Start Index + End Index<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here, we calculate the length dynamically by subtracting the end index from the start index.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To perform subtraction, we use the <code>sub<\/code> function.<\/li>\n\n\n\n<li>For this, you need to know both the <strong>start index<\/strong> (16) and the <strong>end index<\/strong> (19).<\/li>\n<\/ul>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'), \n   16, \n   sub(19,16))\n<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><br><code>fox<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_3_Substring_by_Start_Marker_End_Marker\"><\/span>\ud83d\udd39 3. Substring by Start Marker + End Marker<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This approach is useful when you don\u2019t know the exact index but do know the surrounding text markers-for example, &#8220;jumps&#8221; and &#8220;lazy&#8221;. In this case, we calculate the start index and end index using these markers.<\/p>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'),\n   indexOf(variables('Input Text'),'<strong>jumps<\/strong>'),\n   sub(indexOf(variables('Input Text'),'<strong>lazy<\/strong>'),\n       indexOf(variables('Input Text'),'<strong>jumps<\/strong>')))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><br><code>jumps over the<\/code><\/p>\n\n\n\n<p><strong>Note:<\/strong> When using this method, be careful with your chosen markers. If the end marker appears before the start marker, the expression will throw an error. For example, using <strong>&#8220;the&#8221;<\/strong> as the end marker will fail because it occurs earlier in the text (before &#8220;jumps&#8221;). Even if the marker appears multiple times, Power Automate will pick the <em>first<\/em> occurrence it finds.<\/p>\n\n\n\n<p>\u2705 <strong>Safer Approach:<\/strong><br>If you know your end marker appears multiple times and you want the <em>last occurrence<\/em>, use the <strong><code>lastIndexOf()<\/code><\/strong> function instead of <code>indexOf()<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_4_Substring_from_Start_Index_Until_End\"><\/span>\ud83d\udd39 4. Substring from Start Index Until End<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you only specify the start index and calculate length until the end of the string, you can capture the rest of the text.<\/p>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'),\n   31,\n   sub(length(variables('Input Text')),31))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><br><code>the lazy dog<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_5_Substring_from_Start_to_Midpoint\"><\/span>\ud83d\udd39 5. Substring from Start to Midpoint<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also take the first half of a string by dividing its length in half.<\/p>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'),\n   0,\n   div(length(variables('Input Text')),2))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><br><code>The quick brown fox j<\/code><\/p>\n\n\n\n<p>This method uses the <code>length()<\/code> function to calculate the total length of the text, then divides it by 2 using the <code>div()<\/code> function to find the midpoint index.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%94%B9_6_Substring_from_Midpoint_to_End\"><\/span>\ud83d\udd39 6. Substring from Midpoint to End<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also extract the last half of a string by starting from the midpoint and continuing until the end.<\/p>\n\n\n\n<p><strong>Expression:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>substring(variables('Input Text'),\n   div(length(variables('Input Text')),2),\n   sub(length(variables('Input Text')),\n       div(length(variables('Input Text')),2)))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>umps over the lazy dog<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%F0%9F%93%88_Why_This_Matters\"><\/span>\ud83d\udcc8 Why This Matters<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Ultimate Power Automate Substring Function Explained tutorial demonstrates how flexible text manipulation can be. Whether you need to parse file names, extract IDs from an email subject, or trim unwanted text, substring gives you precise control over your data.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E2%9C%85_Wrapping_Up\"><\/span>\u2705 Wrapping Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now you\u2019ve seen the Ultimate Power Automate Substring Function Explained with 6 practical variations. These examples will help you handle different scenarios where you need text extraction in your flows.<\/p>\n\n\n\n<p>\ud83d\udc49 Try experimenting with different markers, indexes, and dynamic values in your own Power Automate solutions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"_%F0%9F%9A%80_Bonus_tutorials\"><\/span>&nbsp;\ud83d\ude80 Bonus tutorials:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/email-attachments-to-teams\/\">\ud83d\udd043 Effortless Steps to Save Email Attachments to Teams<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/ai-draft-reply-flow\/\">\ud83d\udd04Master Power Automate AI Draft Reply Flow in 7 Steps for Effortless Email Replies<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/populate-word-document\/\">\ud83d\udd044 Easy Steps \u2013 Populate Word Document Without Premium License<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If you have ever needed to extract part of a string in your flow, this tutorial will guide you through the Ultimate Power Automate Substring Function Explained with step-by-step examples. Whether you\u2019re building automation for email parsing, document naming, or text extraction, the substring function will quickly become one of your most useful tools in &#8230; <a title=\"Ultimate Power Automate Substring Function Explained &#8211; 6 Powerful Examples\" class=\"read-more\" href=\"https:\/\/www.techpolaju.com\/blog\/power-automate\/substring-function\/\" aria-label=\"Read more about Ultimate Power Automate Substring Function Explained &#8211; 6 Powerful Examples\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-958","post","type-post","status-publish","format-standard","hentry","category-power-automate"],"_links":{"self":[{"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/posts\/958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/comments?post=958"}],"version-history":[{"count":9,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/posts\/958\/revisions"}],"predecessor-version":[{"id":976,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/posts\/958\/revisions\/976"}],"wp:attachment":[{"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/media?parent=958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/categories?post=958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techpolaju.com\/blog\/wp-json\/wp\/v2\/tags?post=958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}