Click here to Skip to main content
15,886,003 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I want to split the string which starting first character is "F"
C#
List<string> lstTxtAction = new List<string>();
            string[] str = Regex.Split(txtAction, @"\W");

            foreach (string value in str)
                if (!string.IsNullOrEmpty(value))
                    lstTxtAction.Add(value);</string></string>
Posted
Updated 13-Feb-16 19:21pm
v2
Comments
Kenneth Haugland 14-Feb-16 1:18am    
Did you read the documentation?
https://msdn.microsoft.com/en-us/library/8yttk7sy(v=vs.110).aspx

You should write something like:
string MyString = "SplitFSplit";
Regex.Split(MyString, "F");
Merajuddin Ansari 14-Feb-16 1:25am    
i want something like for ex:
say string is : Field1 - Field2

so i need result as:
Field1 and Filed2

1 solution

Do yourself a favor and stop putting random code together and ask why it don't work.
Regex is a powerful tool but you have to learn how to use it.
Read documentation, follow examples and tutorials until you understand.
 
Share this answer
 
Comments
Merajuddin Ansari 14-Feb-16 1:39am    
thank you

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



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