有一列内容如下:
***$$$****
*代表数字,$代表字母,个数不确定怎么样把字母全部取出来?

解决方案 »

  1.   

    select left(col,patindex('%[^0-9]%',col)-1)如果内容是:$$$***$$$***
    *代表数字,$代表字母,个数不确定怎么提出第二部分的字母呢
      

  2.   

    create function ReserveLetter (@oldstr varchar(100)) returns varchar(100)
    as
      begin
        --declare @oldstr varchar(100)
        declare @i int
        --set @oldstr='asdVBD123中国'; 
        set @i = 1
        while @i <= len(@oldstr)
        if substring(@oldstr, @i, 1) like('[^a-z A-Z]')
           set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '')
        else
           set @i = @i +1
        --Print @oldstr
        return @oldstr
    end
      

  3.   

    string s=""
    s=Regex.Replace(s,@"\d+","");
      

  4.   


    发错版了,该发在sql版的,Sorry
      

  5.   

    要求是类似select left(col,patindex('%[^0-9]%',col)-1)
    这样一句,把列中的字母提出来,可行吗
      

  6.   

    用for循环循环这个字符串。每次循环里面就是char类型的值了。char有个方法:算了  我写一下吧 public static void a()
            {
                string sql = "abcd";
                for (int i = 0; i < sql.Length; i++)
                {
                    char a = sql[i];
                    char.IsNumber(a);
                }
            }
    你看看这个方法。是返回bool类型的。这就好解决问题了。
      

  7.   

    如下代码,已通过测试:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RegexTest.aspx.cs" Inherits="RegexTest" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <input id="strOriginal" type="text" value="123azx453" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="提取" OnClick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;public partial class RegexTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string str = strOriginal.Value.ToString().Trim();
            str = Regex.Replace(str,@"\d+","");
            strOriginal.Value = str;
        }
    }