Find only Numbers in an arbitrary string

Jun 5, 2012 at 8:53 PM

Hello, i have a long string of arbitrary code:

like: "fklkljagjg akljgt tgf gdfajk 565 diltysgbhnmf gjklaydjf g añlkjf5 46lla56kjfd"

want to extract just

565, 5, 46, 56

How can i do it using irony?

Thanks!

 

 

 

 

Coordinator
Jun 6, 2012 at 3:02 AM

i don't think Irony is a good choice for this - you be better by just scanning the string char by char and finding numbers

Roman

Jul 4, 2012 at 9:29 PM

Try Regular Expressions

var input = "fklkljagjg akljgt tgf gdfajk 565 diltysgbhnmf gjklaydjf g añlkjf5 46lla56kjfd";
var re = new Regex(@"\d{1,}");
foreach (var item in re.Matches(input))
{
    Console.Write(item + ", ");
}