Please help me in regular expression in c# code:
Input: AB12(100).HJI(20).D76R(222)
Expected Output: 100.20.222 ( Integer only in brackets append with dot(.))
Current output: 1210076222
Please find my code below:
C#
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;
namespace CLRPlay
{
public partial class UserDefinedFunctions
{
static readonly Regex _regex = new Regex(@"[^0-9]*", RegexOptions.Compiled);
static readonly string _nR = @"";
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Indexkey(SqlString val)
{
if (val.IsNull) return SqlString.Null;
return _regex.Replace(val.ToString(), _nR);
}
};
}
VulpesRank #55 · 29.2K reputationPosted Aug 23, 2012, 12:39 AM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Aug 23, 2012, 12:46 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 23, 2012, 1:43 AM EDT
@"(?<=\()(\d+)(?=\))"
mahi babu3 reputationPosted Aug 23, 2012, 2:02 AM EDT
very thank full to you . so use full your's code for me
thanks,
mahi