How to take only int from a string in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main() {
        string str = "abc83920xyz";
        
        string result = Regex.Match(str, @"\d+").Value;

        Console.Write(result);
    }
}




/*
run:

83920

*/

 



answered Aug 15, 2023 by avibootz

Related questions

1 answer 112 views
2 answers 278 views
1 answer 175 views
1 answer 47 views
1 answer 113 views
1 answer 172 views
...