共 62 篇文章 |
|
对我们来说,正则表达式指的是您可以用来查找和替换文本模式的文本字符和通配符组合。请执行下列操作之一:若要从列表中选择通配符,请单击“特殊格式”,再单击通配符,然后在“查找内容”框中键入任何其他文本。可使用 \n 通配符搜索表达式,然后将其替换为经过重新排列的表达式。在对表格中的姓名使用此表达式时,您必须首先将该表格转换成... 阅701 转6 评0 公众公开 19-10-26 23:16 |
“[!x-x]”可以用来排除指定范围内的任意单个字符,如:输入“[!c-f]”就可以找到“bay”、“gay”、“lay”等字符,但是不等字符,但是不会找到“cay”、“day”等字符。最后还要注意如果要查找已经被定义为通配符的字符,如“*”、“?”等字符,必须在该字符前面加上反斜杠“\”,如:输入“\*”则表示查找字符“*”。要查找已被定义为通配符... 阅100 转5 评0 公众公开 19-10-26 23:14 |
阅214 转7 评0 公众公开 19-10-26 23:01 |
阅178 转11 评0 公众公开 19-10-26 23:00 |
如上面电子邮箱正则中,”\S”表示一个非不可见字符,我们可以称之为元字符序列.在正则表达式中也可以有字面字符,如邮箱正则的字符“@”,在这时表示的是字面上”@”.所以从形式上观察,正则表达式是由元字符、元字符序列或字面字符组成的,用于描述字符或字符串特征的一个代码模式.正则表达式也可以仅由字面字符组成,如”正则ABC”.1、 创... 阅299 转14 评0 公众公开 19-10-26 22:45 |
在EXCEL表内遇到有规律性的数据需要提取或者替换时,比如在数据中提取时间,身份证号码等,EXCEL内自带的查找替换就难以实现,我们可以利用VBA适用正则表达式去对数据进行匹配。匹配字符串之间的字符:前面的字符(.*?)后面的字符,比如abc123def ,需要匹配abc和def之间的字符的表达式就是abc(.*?)def.在VBA使用正则表达式代码如下:选择需要提... 阅212 转5 评0 公众公开 19-10-26 22:45 |
Sub t2722() Dim regx As New RegExp Dim sr sr = "A12d我A爱56你 A4" With regx .Global = True .Pattern = "[\u4e00-\u9fa5]" Debug.Print .Replace(sr, "") End With End Sub.Sub t344() Dim regex As New RegExp Dim sr, mat, m sr = "100元800块7元" With regex .Global = True .Pattern = "... 阅504 转12 评0 公众公开 19-10-26 22:44 |
如果A列数据以反斜杠结尾,例如A4单元格100g787×1092-白牛皮沙龙纹A/,提取物料名称时需要去除末尾的反斜杠;对于非反斜杠结尾的数据,则提取减号之后的全部字符(包括反斜杠)作为物料名称。Sub RegExpDemo() Dim strTxt As String Dim objRegEx As Object, objMatch As Object Dim objMH As Object, c As Range Dim DataRng As Range Se... 阅101 转5 评0 公众公开 19-10-26 22:43 |
Sub VBA_DEMO_0725() Dim arrData Dim i As Integer Dim dic As Object Dim n As Integer Dim arrRes() Dim arrTmp() Set dic = CreateObject("scripting.dictionary") strTxt = "A-B-D-CC-C-C-F-C-E-C-D-E-CC-F" arrData = Split(strTxt, "-") For i = UBound(arrData) To LBound(arrData) Step -1 If Not dic.... 阅139 转6 评0 公众公开 19-10-26 22:43 |
Sub VBA_DEMO() Dim strTxt As String Dim arrData Dim strData As String Dim i As Integer Dim intAmt As Integer strTxt = "abc100@200@300$def400ghj@500@600" arrData = Split(strTxt, "@") For i = 1 To UBound(arrData) - 1 strData = arrData(i) If IsNumeric(strData) Then intAmt = intAmt + Val(strData) Next ... 阅134 转7 评0 公众公开 19-10-26 22:42 |