Microsoft
Software
Hardware
Network
Question : Extract chars from a string using regex
Hi,
I have some strings like this:
1: Some Text
5-7 More Text
etc.
Now I like to extract the chars from these strings so I like to get thiese results:
1:
Some Text
5-7
More Text
What I tried was this (I don't really know RegEx):
string pattern = @"[A-Za-z]{1,}";
if (Regex.IsMatch(lead, pattern))
{
string[] dummy = Regex.Split(lead, pattern);
}
But the result will be '1:', ' ' and '' - not what I want :-)
So what is the right way to find the first char and get it till the end?
Thanks
Andre
Answer : Extract chars from a string using regex
Try:
Regex.Split(lead, "(?<=^\S+)\s");
Posted via EE Mobile
Random Solutions
Get World Cup ticket in reasonable price
How to check and clear Attention LED
Access VBA set all values of a Yes/No field to no
Javascript form validation problems
How to see the ESXi version
Oracle Fusion Middleware Vs IBM WAS
excel vba script needed
SCCM MSI deployment Post-Installation tasks
Cannot Replicate FREEBUSY from Exchange 2003 to Exchange 2010 - EVENT 14029, 4003,
Migrate SBS 2003 to Server 2008 R2