Monday, 2 June 2014

Regex for getting only number output from string

           
           SPUser oUser = oWeb.CurrentUser;
            string currUserName = oUser.Name;
            if (currUserName.Contains(';'))
            {
                try { currUserName = currUserName.Split(';')[1]; }
                catch (Exception ex) { }
            }
            string loginidno = Regex.Replace(oUser.LoginName, @"\D", "");

No comments:

Post a Comment