What is the best way to use regex and remove everything after (":") using c#
I have a richtextbox and its populated with data that I load .
The data contain bunch of itemcodes some have (colon) and alphanumeric characters I dont need like for instance RE45O7:TAKEMOUT==> I just want to be able to have RE4507
This is what I have but is not working...
string str = rchTxtContent.Text;
string ext = str.Substring(str.LastIndexOf(":") + 1);
Loading

Jignesh TrivediPosted Feb 24, 2015, 12:26 AM
No need to use Regex.
also try...
string str = "wewew:erere:erere:rtr";
int index = str.LastIndexOf(':');
Console.WriteLine(str.Remove(index));
Ekona PikinPosted Feb 23, 2015, 4:37 PM
VulpesPosted Feb 23, 2015, 4:02 PM
string str = rchTxtContent.Text;