here is my code to split a string patter based on regex match.
string[] docPath = Regex.Split("\\\\sds\\dsd\\df\\df\\d\\fd\\D\\sd\\asdsf\\sdf\\D\\dsfsd", @"[\\][A-Z][\\]");
The above code splits input string (hardcoded) into 3 parts ie
I want it to split only on the first occurrence. output i want is :
Can anyone please help me to modify the reg expression? Kindly help.
Use the version of Regex.Split()
that's an instance method which takes a number specifying the maximum number of components to split into:
Regex pattern = new Regex(@"[\\][A-Z][\\]");
string[] docPath = pattern.Split(
"\\\\sds\\dsd\\df\\df\\d\\fd\\D\\sd\\asdsf\\sdf\\D\\dsfsd", 2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.