Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

If I have a delimited text file with a basic delimiter (say | for instance) does it make a difference whether I use a String or a Regex split?

Would I see any performance gains with one versus the other?

I am assuming you would want to use Regex.Split if you have escaped delimiters that you don't want to split on (| for example).

Are there any other reasons to use Regex.Split vs String.Split?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
347 views
Welcome To Ask or Share your Answers For Others

1 Answer

Regex.Split is more capable, but for an arrangement with basic delimitting (using a character that will not exist anywhere else in the string), the String.Split function is much easier to work with.

As far as performance goes, you would have to create a test and try it out. But, don't pre-optimize, unless you know that this function will be the bottleneck for some essential process.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...