Regex to match with digit in the string.
Posted
by Harikrishna
on Stack Overflow
See other posts from Stack Overflow
or by Harikrishna
Published on 2010-05-11T06:55:22Z
Indexed on
2010/05/12
10:34 UTC
Read the original article
Hit count: 399
I will have a different type of string(string will not have fixed format,they will be different every time) from them I want to remove some specific substring.Like the string can be
OPTIDX 26FEB2009 NIFTY CE 2500
OPTIDX NIFTY 30 Jul 2009 4600.00 PE
OPTSTK ICICIBANK 30 Jul 2009 700.00 PA
I want to extract Rs.(digit) from those string and store it into one variable and then in those string there should not be Rs.(digit).
What should be the regex for that ?
EDIT
private string ExtractingRupeesFromString(String str)
{
Match match = Regex.Match(cellRecord, @"(\d+(?:\.\d+)?)\D*$");
return match.Value.ToString();
}
© Stack Overflow or respective owner