2
Answers

Regex problem

yokzu

yokzu

12y
1.1k
1
Hi,
I want to get all IP addresses in an textbox. My codes are below;
---------------------
         Regex desen = new Regex(@"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$");
            Match m = desen.Match(textBox1.Text.ToString());

            while (m.Success)
            {
                textBox2.Text += m.ToString()+"/n";
                m = m.NextMatch();
           
            }
------------------

But When I write 2 or more Ip addresses in textbox1,  program cant find any IP address. When I write 1 IP address, it is find.

How can I find all the IP addresses?

Answers (2)