<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replace a string with a string in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057763#M220682</link>
    <description>&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/561293"&gt;@Snowshoeman&lt;/a&gt;&amp;nbsp;just do an initial search for "s1" inside "s2".&amp;nbsp; If it is, then return the original text so that you do not have an infinite recursion.&amp;nbsp; Or, like typical replace functions, keep track of the position of the last search and&amp;nbsp;so that the replacement text does not itself get searched.&amp;nbsp; Here are both examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-09 082605.png" style="width: 850px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135586i5CE5667EBBF8205E/image-dimensions/850x338?v=v2" width="850" height="338" role="button" title="Screenshot 2026-03-09 082605.png" alt="Screenshot 2026-03-09 082605.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;If you want the flexibility an exhaustive search while having the protection from recursion, then combine both function so that you keep track of the position only if there can be a recursion:&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-09 083310.png" style="width: 863px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135587iCB8336C3713D5C00/image-dimensions/863x179?v=v2" width="863" height="179" role="button" title="Screenshot 2026-03-09 083310.png" alt="Screenshot 2026-03-09 083310.png" /&gt;&lt;/span&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;"check" remembers if "s1" is inside "s2", then in the 'if' function, "pos" is advanced if "check" is true, or it is reset to zero if not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Mar 2026 14:37:12 GMT</pubDate>
    <dc:creator>SPaulis</dc:creator>
    <dc:date>2026-03-09T14:37:12Z</dc:date>
    <item>
      <title>Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057667#M220678</link>
      <description>&lt;P&gt;I have a character replace function.&amp;nbsp; I would like to use it to replace a string with a string.&amp;nbsp; If the user inputted duplicate "OR's" then I want the function to thin out "OR OR" to just "OR".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Sun, 08 Mar 2026 14:28:40 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057667#M220678</guid>
      <dc:creator>Snowshoeman</dc:creator>
      <dc:date>2026-03-08T14:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057676#M220679</link>
      <description>&lt;P&gt;You may try this string replace function.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grafik.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135553i029E100E073DC678/image-size/large?v=v2&amp;amp;px=999" role="button" title="grafik.png" alt="grafik.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Mar 2026 17:28:28 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057676#M220679</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2026-03-08T17:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057739#M220681</link>
      <description>&lt;P&gt;Thank You!&amp;nbsp; I learn so much from this forum!&amp;nbsp; Your suggestion works!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 12:08:50 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057739#M220681</guid>
      <dc:creator>Snowshoeman</dc:creator>
      <dc:date>2026-03-09T12:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057763#M220682</link>
      <description>&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/561293"&gt;@Snowshoeman&lt;/a&gt;&amp;nbsp;just do an initial search for "s1" inside "s2".&amp;nbsp; If it is, then return the original text so that you do not have an infinite recursion.&amp;nbsp; Or, like typical replace functions, keep track of the position of the last search and&amp;nbsp;so that the replacement text does not itself get searched.&amp;nbsp; Here are both examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-09 082605.png" style="width: 850px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135586i5CE5667EBBF8205E/image-dimensions/850x338?v=v2" width="850" height="338" role="button" title="Screenshot 2026-03-09 082605.png" alt="Screenshot 2026-03-09 082605.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;If you want the flexibility an exhaustive search while having the protection from recursion, then combine both function so that you keep track of the position only if there can be a recursion:&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-09 083310.png" style="width: 863px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135587iCB8336C3713D5C00/image-dimensions/863x179?v=v2" width="863" height="179" role="button" title="Screenshot 2026-03-09 083310.png" alt="Screenshot 2026-03-09 083310.png" /&gt;&lt;/span&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;"check" remembers if "s1" is inside "s2", then in the 'if' function, "pos" is advanced if "check" is true, or it is reset to zero if not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 14:37:12 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057763#M220682</guid>
      <dc:creator>SPaulis</dc:creator>
      <dc:date>2026-03-09T14:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057802#M220683</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 16:26:16 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057802#M220683</guid>
      <dc:creator>Snowshoeman</dc:creator>
      <dc:date>2026-03-09T16:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057810#M220685</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/570696"&gt;@SPaulis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/561293"&gt;@Snowshoeman&lt;/a&gt;&amp;nbsp;just do an initial search for "s1" inside "s2".&amp;nbsp; If it is, then return the original text so that you do not have an infinite recursion.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually my suggestion did not use recursion but rather an iteration loop.&lt;/P&gt;
&lt;P&gt;But I like the idea of intercepting the infinite loop that could occur in some cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And since we were just talking about recursion, here is a recursive variant of the string replacement that solves the problem in a similar way.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grafik.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/135590i4B6FFA83ED1C3E2A/image-size/large?v=v2&amp;amp;px=999" role="button" title="grafik.png" alt="grafik.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 16:51:05 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057810#M220685</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2026-03-09T16:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a string with a string</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057813#M220686</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; I will chew on this too.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 16:57:33 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Replace-a-string-with-a-string/m-p/1057813#M220686</guid>
      <dc:creator>Snowshoeman</dc:creator>
      <dc:date>2026-03-09T16:57:33Z</dc:date>
    </item>
  </channel>
</rss>

