ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Split and Get Number from string using Regular Expression in C# and VB.Net<p>Hi&nbsp;PRA,</p> <p>Refer below code.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">string selected = &#34;&#34;; string value = &#34;Part 1 for example&infin;5 Part 2 for practice&infin;3&#34;; string selectedValues = value; for (int i = 1; i &lt; selectedValues.Split(&#39;&infin;&#39;).Length; i++) { string number = System.Text.RegularExpressions.Regex.Match(selectedValues.Split(&#39;&infin;&#39;)[i], @&#34;\d+&#34;).Value; if (!string.IsNullOrEmpty(number.TrimStart(&#39; &#39;))) { selected += number + &#34;,&#34;; } }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb">Dim selected As String = &#34;&#34; Dim value As String = &#34;Part 1 for example&infin;5 Part 2 for practice&infin;3&#34; Dim selectedValues As String = value For i As Integer = 1 To selectedValues.Split(&#34;&infin;&#34;c).Length - 1 Dim number As String = System.Text.RegularExpressions.Regex.Match(selectedValues.Split(&#34;&infin;&#34;c)(i), &#34;\d+&#34;).Value If Not String.IsNullOrEmpty(number.TrimStart(&#34; &#34;c)) Then selected += number &amp; &#34;,&#34; End If Next</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/507744/Split-and-Get-Number-from-string-using-Regular-Expression-in-C-and-VBNet/https://www.aspforums.net:443/Threads/507744/Split-and-Get-Number-from-string-using-Regular-Expression-in-C-and-VBNet/Mon, 25 Feb 2019 00:11:24 GMT