How to search with Regex?

There is a method which returns true or falls depending on whether the string substring.
For example there is a line : 1,2,4,305,10
And at the input 30 or 3 should be falls, but 305 labor.
How to make an expression, I would be very grateful. Just wanted to cut first split'Ohm, but decided to use regex'Ohm ... :)
April 3rd 20 at 18:24
4 answers
April 3rd 20 at 18:26
Solution
(^|,)305($|,)
April 3rd 20 at 18:28
Solution
^305$

string pattern = @"^305$";
 string input = @"305";
 RegexOptions options = RegexOptions.Multiline;
April 3rd 20 at 18:30
Solution
It is possible still so (on your inputh works)

string st = "1,2,4,305,10";
string find = "30";
return (("," + st + ",").IndexOf("," + find + ",") != -1);
April 3rd 20 at 18:32
\b305\b

Find more questions by tags Regular expressionsC#