亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在單元格和循環中使用Microsoft Excel中的正則表達式(正則表達式)

如何在單元格和循環中使用Microsoft Excel中的正則表達式(正則表達式)

GCT1015 2019-05-22 14:35:21
如何在單元格和循環中使用Microsoft Excel中的正則表達式(正則表達式)如何在Excel中使用正則表達式并利用Excel強大的網格設置進行數據操作?單元格函數返回匹配的模式或替換字符串中的值。Sub循環遍歷一列數據并提取匹配到相鄰單元格。需要什么設置?Excel的正則表達式的特殊字符是什么?我的理解正則表達式是不理想的許多情況下(使用或不使用正則表達式?),因為Excel可以使用Left,Mid,Right,Instr類型相似的操作命令。
查看完整描述

3 回答

?
海綿寶寶撒

TA貢獻1809條經驗 獲得超8個贊

這是我的嘗試:


Function RegParse(ByVal pattern As String, ByVal html As String)

    Dim regex   As RegExp

    Set regex = New RegExp


    With regex

        .IgnoreCase = True  'ignoring cases while regex engine performs the search.

        .pattern = pattern  'declaring regex pattern.

        .Global = False     'restricting regex to find only first match.


        If .Test(html) Then         'Testing if the pattern matches or not

            mStr = .Execute(html)(0)        '.Execute(html)(0) will provide the String which matches with Regex

            RegParse = .Replace(mStr, "$1") '.Replace function will replace the String with whatever is in the first set of braces - $1.

        Else

            RegParse = "#N/A"

        End If


    End With

End Function


查看完整回答
反對 回復 2019-05-22
  • 3 回答
  • 0 關注
  • 1055 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號