Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
All,
My previous question was related to splitting the string on multiple delimiters but keep the delimiter so the output for the code below would be

MK
WVTFISLLLLFSSAYSR
GVFR
R
DTHK
SEIAHR
FK
DLGEEHFK
GLVLIAFSQYLQQCPFDEHVK
LVNELTEFAK................etc

I would like to modify so I can incorporate user-defined "missed cleavages" So for example 1 missed cleavages(at R or K) would read: Any suggestions?

MKWVTFISLLLLFSSAYSR
GVFRR
DTHKSEIAHRFK
DLGEEHFKGLVLIAFSQYLQVK

Here is the code:
string input = "MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQVK";
Regex regex = new Regex("([^KR])*[KR]");
MatchCollection ms = regex.Matches(input);
foreach (Match m in ms)
{
  Console.WriteLine(m.Value);
}
Posted
Updated 5-Jun-11 12:24pm
v2
Comments
BobJanova 3-Jun-11 10:45am    
Why are you using a regex? String.Split can do this.
Keith Barrow 5-Jun-11 18:30pm    
BobJanova's suggestion is a really good one. You can keep a List<char> of the characters you wish to split by, and loop over it splitting as you need. If you don't need to keep the split character this is *really* easy.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900