I believe everyone has used it, but I think it is quite helpful, because it is always used to intercept code at ordinary times, so I 'd like to share it with you.
Generally, you can use the built-in split of string, but the split can only be intercepted by char type, which is not very convenient.
Truncate by string and use a regular expression. A simple two-line code solves many problems.
As follows:
String content = @ "Long character"; Regex regex = new Regex (@ "truncated string"); string [] result = regex. Split (content );
Example:
Class Program {static void Main (string [] args) {string content = @ "carrying a paper umbrella,
Wandering alone in the long, long, and lonely Rain Lane,
I hope that
The same as a clove
Sad girl.
She has
The same color as clove,
The fragrance of clove,
Clove-like sorrow,
Grief in the rain,
Sorrow and sorrow;
She is wandering in the lonely Rain Lane,
Oil Paper Umbrella
Like me,
Like me
With
Indifference, clear, and melancholy.
She approached silently,
Approaching and throwing
An ordinary eye
She floated
Like a dream,
It is as miserable and confused as a dream.
Float like a dream
A clove,
This girl floated beside me;
She was far away silently, far away,
To the p branch wall,
Go through the Rain Lane.
In the song of rain,
Remove her color,
The fragrance of her,
Dissipated,
Even her
Eye-catching,
Clove-like melancholy.
Holding a paper umbrella, alone
Long and long
The lonely Rain Lane,
I want to float
The same as a clove
Sad girl. "; Regex regex = new Regex (@"
"); String [] result = regex. Split (content); foreach (string item in result) {Console. WriteLine (item) ;}console. ReadLine ();}}
Result chart:
Although skillful, it can improve work efficiency.