<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Regex &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 02 Jun 2021 15:16:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Regex &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Find Occurrence Of A String</title>
		<link>https://www.sibeeshpassion.com/find-occurrence-of-a-string/</link>
					<comments>https://www.sibeeshpassion.com/find-occurrence-of-a-string/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 05 Aug 2015 00:53:48 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[C-Sharp Functions]]></category>
		<category><![CDATA[Find Occurrence of String]]></category>
		<category><![CDATA[Find String Form String]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[String Contains Substring]]></category>
		<category><![CDATA[Substring]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=7571</guid>

					<description><![CDATA[In this article you will learn the ways to find the occurrence of a string from a string, or find a sub string from a string. We are using C# language to do this demo. In times, you may have faced this requirement. And I am sure you would do that. This article is for the one who don&#8217;t know how to achieve this. We will be discussing two methods here. I hope you will like it. See demo Occurrence Of A String Demo Background Today I have got a requirement of creating a function which performs some operations according [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article you will learn the ways to find the occurrence of a string from a string, or find a sub string from a string. We are using C# language to do this demo. In times, you may have faced this requirement. And I am sure you would do that. This article is for the one who don&#8217;t know how to achieve this. We will be discussing two methods here. I hope you will like it.</p>
<p><span style="color: #ff6600;"><strong>See demo</strong></span></p>
<p><a href="http://sibeeshpassion.com/demo/OccurrenceOfString/" target="_blank" rel="noopener">Occurrence Of A String Demo</a></p>
<p><span style="color: #ff6600;"><strong>Background</strong></span></p>
<p>Today I have got a requirement of creating a function which performs some operations according to the occurrence of a string in a given string. Like, if a string pattern contains more that one time in a given string, it must do some actions and if it is just one time it should do other actions. I have done this in two ways, here I am sharing you that. I hope some one may find it is useful.</p>
<p><span style="color: #ff6600;"><strong>Using the code</strong></span></p>
<p>We are going to discuss the following two ways to achieve this requirement.</p>
<li>Using Regex Class</li>
<li>Using Custom Function</li>
<p>We will start with a Regex class first.</p>
<p>To start with Regex, you need to add another namespace as given below.</p>
<p>[csharp]<br />
using System.Text.RegularExpressions;<br />
[/csharp]</p>
<p>Now consider we have designed our page as follows.</p>
<p>[html]<br />
&lt;div&gt;<br />
            &lt;table &gt;<br />
                &lt;tr&gt;<br />
                    &lt;td&gt;<br />
                        &lt;asp:Label ID=&quot;lblInputString&quot; runat=&quot;server&quot; Text=&quot;Input String&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                    &lt;td&gt;<br />
                        &lt;textarea id=&quot;txtInputString&quot; runat=&quot;server&quot;&gt;&lt;/textarea&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td&gt;<br />
                        &lt;asp:Label ID=&quot;lblPattern&quot; runat=&quot;server&quot; Text=&quot;Pattern String&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                    &lt;td&gt;<br />
                        &lt;textarea id=&quot;txtPattern&quot; runat=&quot;server&quot;&gt;&lt;/textarea&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td colspan=&quot;2&quot;&gt;<br />
                        &lt;asp:Button ID=&quot;btnCheckOccurance&quot; runat=&quot;server&quot; Text=&quot;Check Occurance&quot; OnClick=&quot;btnCheckOccurance_Click&quot; /&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td colspan=&quot;2&quot;&gt;<br />
                        &lt;asp:Label ID=&quot;lblOutput&quot; runat=&quot;server&quot; Text=&quot;See Output Here!!! &lt;i&gt; Thank you for visiting. Please Visit Again!!! &lt;/i&gt;&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
            &lt;/table&gt;<br />
        &lt;/div&gt;<br />
[/html]</p>
<p>And Some CSS styles as follows.</p>
<p>[css]<br />
&lt;style type=&quot;text/css&quot;&gt;<br />
        textarea {<br />
            width: 630px;<br />
            height: 100px;<br />
        }</p>
<p>        table {<br />
            border: 1px solid #ccc;<br />
            padding: 10px;<br />
            width: 800px;<br />
            text-align:center;<br />
        }</p>
<p>        tr {<br />
            border: 1px solid #999;<br />
            border-radius: 5px;<br />
        }</p>
<p>        td {<br />
            border: 1px solid #999;<br />
            padding: 10px;<br />
            border-radius: 5px;<br />
        }<br />
    &lt;/style&gt;<br />
[/css]</p>
<p>If you add the above codes and CSS, your page may looks like in the preceding image.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_1.png" alt="" /></p>
<p>Now we will see our C# code. Please add the below lines of codes in the button click event.</p>
<p>[csharp]<br />
protected void btnCheckOccurance_Click(object sender, EventArgs e)<br />
    {<br />
        int occuranceCount = 0;</p>
<p>        //Checking Occurance<br />
        occuranceCount = Regex.Matches(txtInputString.Value.ToLower().Trim(), txtPattern.Value.ToLower().Trim()).Count;<br />
        if (occuranceCount &gt; 0)<br />
            lblOutput.Text = &quot;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Sibeesh Passion &lt;/b&gt;Says &lt;br/&gt;&lt;br/&gt;The given string pattern &lt;i&gt;&quot; + txtPattern.Value + &quot;&lt;/i&gt; Contains &quot; + occuranceCount + &quot; times in  &lt;i&gt;&quot;<br />
                + txtInputString.Value + &quot;&lt;/i&gt;&lt;br/&gt;&lt;br/&gt; Thank you for visiting. Please Visit Again!!!&quot;;<br />
        else<br />
            lblOutput.Text = &quot;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Sibeesh Passion &lt;/b&gt;Says &lt;br/&gt;&lt;br/&gt;The given string pattern &lt;i&gt;&quot; + txtPattern.Value + &quot;&lt;/i&gt; Is not occured s in  &lt;i&gt;&quot;<br />
                + txtInputString.Value + &quot;&lt;/i&gt;&lt;br/&gt;&lt;br/&gt; Thank you for visiting. Please Visit Again!!!&quot;;<br />
        //End<br />
    }<br />
[/csharp]</p>
<p>In the above code, we are finding the occurrence of a string by using a <em>Regex.Matches</em> function. The <em>Regex.Matches</em> function expects two parameters. </p>
<li>Input String (In which string we need to search for a string)</li>
<li>Pattern String(What we need to search in a string)</li>
<p>We are getting those two values from our texarea and pass as follows.</p>
<p>[csharp]<br />
Regex.Matches(txtInputString.Value.ToLower().Trim(), txtPattern.Value.ToLower().Trim()).Count;<br />
[/csharp]</p>
<p>Now if you run application, you will get output as follows.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex.png"><img fetchpriority="high" decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex-300x185.png" alt="Find_Occurrence_Of_A_String_Using_Regex" width="300" height="185" class="alignnone size-medium wp-image-7611" srcset="/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex-300x185.png 300w, /wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex-768x474.png 768w, /wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex-400x247.png 400w, /wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex.png 813w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex_2-e1437475061191.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Regex_2-300x183.png" alt="Find_Occurrence_Of_A_String_Using_Regex_2" width="300" height="183" class="alignnone size-medium wp-image-7621" /></a></p>
<p>As you can see I have given the words, &#8220;Sibeesh&#8221; and &#8220;passion&#8221; for testing, and it gave the correct number of occurrence right?</p>
<p>Now we will see how we can do this by Using a Custom Function.</p>
<p>Following in our function call.</p>
<p>[csharp]<br />
occuranceCount = FindOccurrences(txtInputString.Value.ToLower().Trim(), txtPattern.Value.ToLower().Trim());<br />
[/csharp]</p>
<p>And please find the function body below.</p>
<p>[csharp]<br />
 #region FindOccurrences<br />
    /// &lt;summary&gt;<br />
    /// This method is used to get the Count of Occurrences of a string in a string<br />
    /// &lt;/summary&gt;<br />
    /// &lt;param name=&quot;InputString&quot;&gt;&lt;/param&gt;<br />
    /// &lt;param name=&quot;patternString&quot;&gt;&lt;/param&gt;<br />
    /// &lt;returns&gt;Int&lt;/returns&gt;<br />
    public int FindOccurrences(string InputString, string patternString)<br />
    {<br />
        // Here we are looping through InputString<br />
        int intCount = 0;<br />
        int i = 0;<br />
        while ((i = InputString.IndexOf(patternString, i)) != -1)<br />
        {<br />
            i += patternString.Length;<br />
            intCount++;<br />
        }<br />
        return intCount;<br />
    }<br />
    #endregion<br />
[/csharp]</p>
<p>Now if your run you will get the same output as we got by using a Regex function.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Custom_Function-e1437475554507.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Custom_Function-300x184.png" alt="Find_Occurrence_Of_A_String_Using_Custom_Function" width="300" height="184" class="alignnone size-medium wp-image-7631" /></a></p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Custom_Function_2-e1437475574384.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/07/Find_Occurrence_Of_A_String_Using_Custom_Function_2-300x184.png" alt="Find_Occurrence_Of_A_String_Using_Custom_Function_2" width="300" height="184" class="alignnone size-medium wp-image-7641" /></a></p>
<p>Now we will see our complete codes.</p>
<p><strong>Complete Code</strong></p>
<p><em>Default.aspx.cs</em></p>
<p>[csharp]<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text.RegularExpressions;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;</p>
<p>public partial class _Default : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {</p>
<p>    }<br />
    protected void btnCheckOccurance_Click(object sender, EventArgs e)<br />
    {<br />
        int occuranceCount = 0;</p>
<p>        //Checking Occurance<br />
        //occuranceCount = Regex.Matches(txtInputString.Value.ToLower().Trim(), txtPattern.Value.ToLower().Trim()).Count;<br />
        occuranceCount = FindOccurrences(txtInputString.Value.ToLower().Trim(), txtPattern.Value.ToLower().Trim());<br />
        if (occuranceCount &gt; 0)<br />
            lblOutput.Text = &quot;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Sibeesh Passion &lt;/b&gt;Says &lt;br/&gt;&lt;br/&gt;The given string pattern &lt;i&gt;&quot; + txtPattern.Value + &quot;&lt;/i&gt; Contains &quot; + occuranceCount + &quot; times in  &lt;i&gt;&quot;<br />
                + txtInputString.Value + &quot;&lt;/i&gt;&lt;br/&gt;&lt;br/&gt; Thank you for visiting. Please Visit Again!!!&quot;;<br />
        else<br />
            lblOutput.Text = &quot;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Sibeesh Passion &lt;/b&gt;Says &lt;br/&gt;&lt;br/&gt;The given string pattern &lt;i&gt;&quot; + txtPattern.Value + &quot;&lt;/i&gt; Is not occured s in  &lt;i&gt;&quot;<br />
                + txtInputString.Value + &quot;&lt;/i&gt;&lt;br/&gt;&lt;br/&gt; Thank you for visiting. Please Visit Again!!!&quot;;<br />
        //End<br />
    }<br />
    #region FindOccurrences<br />
    /// &lt;summary&gt;<br />
    /// This method is used to get the Count of Occurrences of a string in a string<br />
    /// &lt;/summary&gt;<br />
    /// &lt;param name=&quot;InputString&quot;&gt;&lt;/param&gt;<br />
    /// &lt;param name=&quot;patternString&quot;&gt;&lt;/param&gt;<br />
    /// &lt;returns&gt;Int&lt;/returns&gt;<br />
    public int FindOccurrences(string InputString, string patternString)<br />
    {<br />
        // Here we are looping through InputString<br />
        int intCount = 0;<br />
        int i = 0;<br />
        while ((i = InputString.IndexOf(patternString, i)) != -1)<br />
        {<br />
            i += patternString.Length;<br />
            intCount++;<br />
        }<br />
        return intCount;<br />
    }<br />
    #endregion<br />
}<br />
[/csharp]</p>
<p><em>Default.aspx</em></p>
<p>[html]<br />
&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&gt;</p>
<p>&lt;!DOCTYPE html&gt;</p>
<p>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head runat=&quot;server&quot;&gt;<br />
    &lt;title&gt;Find Occurrence of String,Find String Form String,Regex,String Contains Substring &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;style type=&quot;text/css&quot;&gt;<br />
        textarea {<br />
            width: 630px;<br />
            height: 100px;<br />
        }</p>
<p>        table {<br />
            border: 1px solid #ccc;<br />
            padding: 10px;<br />
            width: 800px;<br />
            text-align:center;<br />
        }</p>
<p>        tr {<br />
            border: 1px solid #999;<br />
            border-radius: 5px;<br />
        }</p>
<p>        td {<br />
            border: 1px solid #999;<br />
            padding: 10px;<br />
            border-radius: 5px;<br />
        }<br />
    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;<br />
        &lt;div&gt;<br />
            &lt;table &gt;<br />
                &lt;tr&gt;<br />
                    &lt;td&gt;<br />
                        &lt;asp:Label ID=&quot;lblInputString&quot; runat=&quot;server&quot; Text=&quot;Input String&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                    &lt;td&gt;<br />
                        &lt;textarea id=&quot;txtInputString&quot; runat=&quot;server&quot;&gt;&lt;/textarea&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td&gt;<br />
                        &lt;asp:Label ID=&quot;lblPattern&quot; runat=&quot;server&quot; Text=&quot;Pattern String&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                    &lt;td&gt;<br />
                        &lt;textarea id=&quot;txtPattern&quot; runat=&quot;server&quot;&gt;&lt;/textarea&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td colspan=&quot;2&quot;&gt;<br />
                        &lt;asp:Button ID=&quot;btnCheckOccurance&quot; runat=&quot;server&quot; Text=&quot;Check Occurance&quot; OnClick=&quot;btnCheckOccurance_Click&quot; /&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
                &lt;tr&gt;<br />
                    &lt;td colspan=&quot;2&quot;&gt;<br />
                        &lt;asp:Label ID=&quot;lblOutput&quot; runat=&quot;server&quot; Text=&quot;See Output Here!!! &lt;i&gt; Thank you for visiting. Please Visit Again!!! &lt;/i&gt;&quot;&gt;&lt;/asp:Label&gt;<br />
                    &lt;/td&gt;<br />
                &lt;/tr&gt;<br />
            &lt;/table&gt;<br />
        &lt;/div&gt;<br />
    &lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Validation</strong></p>
<p>Now if you want you can add some basic validation to your code in server side and client side. I will always recommend you to do both validation.</p>
<p><em>Server Side</em><br />
[csharp]<br />
if (txtInputString.Value.ToLower().Trim() != &quot;&quot; &amp;&amp; txtPattern.Value.ToLower().Trim() != &quot;&quot;)<br />
        {<br />
}<br />
[/csharp]</p>
<p>Place the button click event code inside of this if condition.</p>
<p><em>Client Side</em></p>
<p><em>Add a Jquery reference </em></p>
<p>[js]<br />
&lt;script src=&quot;jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>And add the below scripts.</p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
            $(&#8216;#btnCheckOccurance&#8217;).click(function () {<br />
                if ($(&#8216;#txtInputString&#8217;).val() == &quot;&quot; || $(&#8216;#txtPattern&#8217;).val() == &quot;&quot;) {<br />
                    alert(&#8216;Values can not be empty&#8217;);<br />
                    return false;<br />
                }<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p><span style="color: #ff6600;"><strong>Conclusion</strong></span></p>
<p>I hope someone found this article useful. Please share me your valuable thoughts and comments. Your feedback is always welcomed.</p>
<p>Thanks in advance. Happy coding!</p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank" rel="noopener">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/find-occurrence-of-a-string/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to replace number from a string in C#</title>
		<link>https://www.sibeeshpassion.com/how-to-replace-number-from-a-string-in-csharp/</link>
					<comments>https://www.sibeeshpassion.com/how-to-replace-number-from-a-string-in-csharp/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 24 Jun 2015 09:32:10 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[C# functions]]></category>
		<category><![CDATA[C# Regex]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[find number]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Replace number]]></category>
		<category><![CDATA[replace number from string]]></category>
		<category><![CDATA[separate number and string]]></category>
		<category><![CDATA[Take number from string]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5401</guid>

					<description><![CDATA[In this pose we will see how to replace a number from a string in C#. We can do this in several ways. Here I am going to show you one. I hope you will like this. Consider following is my string. [csharp] String myString = &#34;MyString1&#34;; [/csharp] And I need to take out the number 1 from the value MyString1. What will we do? To do this we can use Regex class in C#. Following is the code to achieve the same 🙂 [csharp] myString = Regex.Replace(sortdatafield, @&#34;[\d-]&#34;, string.Empty); [/csharp] Once you done and Run, you will get the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this pose we will see how to replace a number from a string in C#. We can do this in several ways. Here I am going to show you one. I hope you will like this.</p>
<p>Consider following is my string.</p>
<p>[csharp]<br />
String myString = &quot;MyString1&quot;;<br />
[/csharp]</p>
<p>And I need to take out the number <em>1 </em>from the value <em>MyString1</em>. What will we do?</p>
<p>To do this we can use Regex class in C#. Following is the code to achieve the same 🙂</p>
<p>[csharp]<br />
myString = Regex.Replace(sortdatafield, @&quot;[\d-]&quot;, string.Empty);<br />
[/csharp]</p>
<p>Once you done and Run, you will get the new value  without numbers (<em>&#8220;MyString&#8221;</em>) in the variable <em>myString</em></p>
<p>I hope someone found this useful. Happy Coding 🙂</p>
<p>Kindly see my code snippets <a href="http://sibeeshpassion.com/category/code-snippets/" target="_blank" rel="noopener">here</a></p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank" rel="noopener">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/how-to-replace-number-from-a-string-in-csharp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to take numbers from a string in C#</title>
		<link>https://www.sibeeshpassion.com/how-to-take-numbers-from-a-string-in-csharp/</link>
					<comments>https://www.sibeeshpassion.com/how-to-take-numbers-from-a-string-in-csharp/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 24 Jun 2015 09:24:03 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[C# functions]]></category>
		<category><![CDATA[C# Regex]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[find number]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[separate number and string]]></category>
		<category><![CDATA[Take number from string]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5381</guid>

					<description><![CDATA[Consider following is my string. [csharp] String myString = &#34;MyString1&#34;; [/csharp] And I need to take out the number 1 from the value MyString1. What will we do? To do this we can use Regex class in C#. Following is the code to achieve the same 🙂 [csharp] myString = Regex.Match(myString , @&#34;\d+&#34;).Value; [/csharp] Once you done and Run, you will get value 1 in the variable myString I hope someone found this useful. Happy Coding 🙂 Kindest Regards Sibeesh Venu]]></description>
										<content:encoded><![CDATA[<p>Consider following is my string.<br />
[csharp]<br />
String myString = &quot;MyString1&quot;;<br />
[/csharp]</p>
<p>And I need to take out the number <em>1 </em>from the value <em>MyString1</em>. What will we do?</p>
<p>To do this we can use Regex class in C#. Following is the code to achieve the same 🙂</p>
<p>[csharp]<br />
myString = Regex.Match(myString , @&quot;\d+&quot;).Value;<br />
[/csharp]</p>
<p>Once you done and Run, you will get value <em>1</em> in the variable <em>myString </em></p>
<p>I hope someone found this useful. Happy Coding 🙂</p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank" rel="noopener">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/how-to-take-numbers-from-a-string-in-csharp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
