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 192 views
2 answers 410 views
1 answer 263 views
1 answer 149 views
1 answer 202 views
1 answer 259 views
...