regex - 匹配除 ' 之外的任何字符

标签 regex vba vba7 vba6

我想匹配任何字符(不区分大小写),除非前面是单引号,后跟文本 On Error Goto:

匹配:

on error goto err_handler
if aap = 0 then on error goto Myerrorhandler
    on error goto errorhandler1
   on error goto errorhandler2

不匹配:

' on error goto errorhandler3
'   if aap =0 then on error goto errorhandler4
Any line not containing On Error Goto

我尝试过:[^']*(On Error Goto) 但这不起作用。

测试程序中是否使用Errorhandler

谢谢!

最佳答案

使用

^[^'\n\r]*On Error Goto

使用i不区分大小写模式和m多行模式。请参阅proof .

说明

--------------------------------------------------------------------------------
  ^                        the beginning of the string
--------------------------------------------------------------------------------
  [^'\n\r]*                any character except: ''', '\n' (newline),
                           '\r' (carriage return) (0 or more times
                           (matching the most amount possible))
--------------------------------------------------------------------------------
  On Error Goto            'On Error Goto'

关于regex - 匹配除 ' 之外的任何字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64297790/

相关文章:

用于替换格式但保留单元格值 : partially solved 的 VBA

csv - 是否可以通过 VBA 检查 csv 文件中是否有任何数据?

excel - 无论计算模式如何,您将如何编写手动计算的 excel udf?

excel - 如何使用 VBA 从不同列上显示的包装文本中获取文本

excel - 根据许多值删除整行

javascript - RegExp - 替换搜索中的 `html` 标签并突出显示

php - 将字符串拆分为数组正则表达式 php

c# - 找不到正确的正则表达式模式来获取 html 标签之间的值