Click here to Skip to main content
15,895,746 members
Home / Discussions / C#
   

C#

 
QuestionRegex for String.Contains Pin
amrok2amrokk10-May-12 23:09
amrok2amrokk10-May-12 23:09 
AnswerRe: Regex for String.Contains Pin
Abhinav S10-May-12 23:19
Abhinav S10-May-12 23:19 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk10-May-12 23:32
amrok2amrokk10-May-12 23:32 
AnswerRe: Regex for String.Contains Pin
Pete O'Hanlon10-May-12 23:48
mvePete O'Hanlon10-May-12 23:48 
GeneralRe: Regex for String.Contains Pin
Manfred Rudolf Bihy11-May-12 0:28
professionalManfred Rudolf Bihy11-May-12 0:28 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 3:24
mvePIEBALDconsult11-May-12 3:24 
AnswerRe: Regex for String.Contains Pin
OriginalGriff11-May-12 3:52
mveOriginalGriff11-May-12 3:52 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 4:28
amrok2amrokk11-May-12 4:28 
So I created a simple test and here are the results:
Regex 00:00:00.2968750
String 00:00:00.3281250
It's for release configuration.

C#
namespace RegexTest
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        List<string> _data;

        public Window1()
        {
            InitializeComponent();

            _data = new List<string>(500000);

            Random rand = new Random();
            byte[] data = new byte[4000];

            //int count = _data.Count;

            for (int i = 0; i < 50000; i++)
            {
                rand.NextBytes(data);
                _data.Add(Convert.ToBase64String(data));
            }
        }

        private void buttonTestRegex_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = DateTime.Now;

            Regex regex = new Regex("99");
            int count = _data.Count;
            int match = 0;
            for (int i = 0; i < count; i++)
            {
                if (regex.IsMatch(_data[i]))
                {
                    match++;
                }
            }

            DateTime end = DateTime.Now;

            this.textBoxRegex.Text = (end - start).ToString();
        }

        private void buttonTestString_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = DateTime.Now;

            int count = _data.Count;
            int match = 0;
            for (int i = 0; i < count; i++)
            {
                if (_data[i].Contains("99"))
                {
                    match++;
                }
            }

            DateTime end = DateTime.Now;

            this.textBoxString.Text = (end - start).ToString();
        }
    }
}

GeneralRe: Regex for String.Contains Pin
OriginalGriff11-May-12 4:55
mveOriginalGriff11-May-12 4:55 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 5:07
amrok2amrokk11-May-12 5:07 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 5:30
mvePIEBALDconsult11-May-12 5:30 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 5:59
amrok2amrokk11-May-12 5:59 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 5:09
mvePIEBALDconsult11-May-12 5:09 
GeneralRe: Regex for String.Contains Pin
jschell11-May-12 13:46
jschell11-May-12 13:46 
AnswerRe: Regex for String.Contains Pin
BobJanova11-May-12 3:58
BobJanova11-May-12 3:58 
QuestionGraphicsDeviceServce Pin
Philip Solomon See10-May-12 13:08
Philip Solomon See10-May-12 13:08 
AnswerRe: GraphicsDeviceServce Pin
Richard MacCutchan10-May-12 22:02
mveRichard MacCutchan10-May-12 22:02 
Questionsend data from google api v3 javascript to c# Pin
mrx10010-May-12 11:12
mrx10010-May-12 11:12 
AnswerRe: send data from google api v3 javascript to c# Pin
Gerry Schmitz10-May-12 13:01
mveGerry Schmitz10-May-12 13:01 
AnswerRe: send data from google api v3 javascript to c# Pin
loyal ginger11-May-12 4:34
loyal ginger11-May-12 4:34 
GeneralRe: send data from google api v3 javascript to c# Pin
mrx10011-May-12 10:50
mrx10011-May-12 10:50 
GeneralRe: send data from google api v3 javascript to c# Pin
loyal ginger14-May-12 3:33
loyal ginger14-May-12 3:33 
Questiondrawing on one form and display it on another form Pin
borrasanjay10-May-12 9:44
borrasanjay10-May-12 9:44 
AnswerRe: drawing on one form and display it on another form Pin
Luc Pattyn10-May-12 11:15
sitebuilderLuc Pattyn10-May-12 11:15 
GeneralRe: drawing on one form and display it on another form Pin
borrasanjay10-May-12 14:04
borrasanjay10-May-12 14:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.