<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to parse data from a string, specifically how do I find the index of the first character that&amp;#39;s a number?</title><link>https://community.appian.com/discussions/f/data/23781/how-to-parse-data-from-a-string-specifically-how-do-i-find-the-index-of-the-first-character-that-s-a-number</link><description>So I&amp;#39;ve got an API integration that returns data in a single string field and I&amp;#39;d like to extract sections of the data to put into separate CDT fields. So the string that&amp;#39;s returned will look something like this: &amp;quot;Advil 20 MG/ML Oral Suspension&amp;quot;. I&amp;#39;d</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91402?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 15:53:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:89823d2a-0b33-47c2-ac19-911b631ce6bd</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="85715" url="~/discussions/f/data/23781/how-to-parse-data-from-a-string-specifically-how-do-i-find-the-index-of-the-first-character-that-s-a-number/91401#91401"]get the number itself[/quote]
&lt;p&gt;Oh - I was thinking of the OP&amp;#39;s question which was, &amp;quot;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&lt;em&gt;What I&amp;#39;m wondering is how do I get the &lt;strong&gt;index of&lt;/strong&gt; the first character that&amp;#39;s a number?&lt;/em&gt;&amp;quot;, which is what the above is.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91401?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 15:51:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:74206bc0-f818-48a0-8759-3a57e39adb1e</guid><dc:creator>Richard Michaelis</dc:creator><description>&lt;p&gt;hahahaha made my day.&lt;br /&gt;but the target was to get the number itself, if I got it right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91395?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 15:06:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5afb5a4b-5a55-4377-bc54-d30c49f6d3b8</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="85715" url="~/discussions/f/data/23781/how-to-parse-data-from-a-string-specifically-how-do-i-find-the-index-of-the-first-character-that-s-a-number/91388#91388"]I got 7 as result?[/quote]
&lt;p&gt;Seems correct to me (?)&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1645542381559v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91393?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 15:01:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d419ba80-3e1a-4a65-8124-1901abdf989e</guid><dc:creator>Joe Spain</dc:creator><description>&lt;p&gt;Thanks! This is the one I went with. Works great, I appreciate the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91389?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:44:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6406982a-102c-4799-a0ee-f37a0ae0d0a4</guid><dc:creator>Richard Michaelis</dc:creator><description>&lt;p&gt;try this for string&lt;br /&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!string:&amp;quot;Advil XX MG/ML Oral Suspension&amp;quot;,
  stripwith(tostring(regexallmatches(&amp;quot;[0-9]&amp;quot;,local!string)), &amp;quot;; &amp;quot;)
)&lt;/pre&gt;&lt;br /&gt;This one if you want to archive an integer output:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!string:&amp;quot;Advil XX MG/ML 20 Oral Suspension&amp;quot;,
  tointeger(tostring(regexallmatches(&amp;quot;[0-9]&amp;quot;,local!string)))
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91388?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:40:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:711b09b7-4e37-4e41-8d53-831447997170</guid><dc:creator>Richard Michaelis</dc:creator><description>&lt;p&gt;I got 7 as result?&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1645540849332v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91386?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:34:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a4ab5ab1-8986-4794-8f17-454b41b71223</guid><dc:creator>GopalK</dc:creator><description>&lt;p&gt;Yes, In that case null check can be applied,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!string: &amp;quot;Advil xx MG/ML Oral Suspension&amp;quot;,
  if(
    a!isNullOrEmpty(regexfirstmatch(&amp;quot;[0-9]&amp;quot;, local!string)),
    &amp;quot;&amp;quot;,
    find(
      regexfirstmatch(&amp;quot;[0-9]&amp;quot;, local!string),
      local!string
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91382?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:27:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:aeab5927-2909-4e66-a0a0-072f068ec190</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Neater...but if the string contains no numbers it throws an error:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!string:&amp;quot;Advil XX MG/ML Oral Suspension&amp;quot;,
  find(regexfirstmatch(&amp;quot;[0-9]&amp;quot;,local!string),local!string)

)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...results in:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1645540094969v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91379?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:25:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3d253ba4-6be1-4608-826f-0055639625e5</guid><dc:creator>GopalK</dc:creator><description>&lt;p&gt;Hi, You can try below code as well.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!string:&amp;quot;Advil 20 MG/ML Oral Suspension&amp;quot;,
  find(regexfirstmatch(&amp;quot;[0-9]&amp;quot;,local!string),local!string)
  
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to parse data from a string, specifically how do I find the index of the first character that's a number?</title><link>https://community.appian.com/thread/91371?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:01:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c98f4fcb-176e-475c-b323-4f934d5927fc</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;I&amp;#39;m sure there are more elegant ways, but you can use the following fragment to return a list of indices for every possible numeric value:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;fn!wherecontains(
  {&amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;,&amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;5&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;7&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;9&amp;quot;},
  fn!char(fn!code(&amp;quot;Advil 20 MG/ML Oral Suspension&amp;quot;))
)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If the returned array is empty, then your string contains no numerics, otherwise the first item in the array is the index of the first number.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>