c# - RegEx vs string manipulation functions: What is better -
if have find let's word in sentence, can think of 2 approaches
- using string.indexof
- using regex
which 1 better in terms of performance or best practice
it depends on exact requirements. if need find word in sentence (not substring), believe expressed more concisely , more explicitly using well-named regex pattern using indexof plus logic make sure you're getting complete single word.
on other hand, if you're looking substring, indexof far superior in terms of performance , readability.
Comments
Post a Comment