Ad
  • Custom User Avatar

    On my side the regex code is twice as slow as a for loop (2526 ms vs 1149 ms).

  • Custom User Avatar

    I do a foreach loop for 1_000_000 repetitions of the "yacht is the sea with a man in the sky" line discussed above, and compare it to regex.
    Results:
    1280 ms - for loop
    1137 ms - regex
    the for loop loses an average of 100 ms. LINQ is slower - 1809 ms

    Summary: regex is the fastest and most obvious - really best practice)))