Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 搜索并替换为正则表达式(包括lookbehinds)在VS2017中不起作用_.net_Regex_Visual Studio 2017_Lookbehind_Find Replace - Fatal编程技术网

.net 搜索并替换为正则表达式(包括lookbehinds)在VS2017中不起作用

.net 搜索并替换为正则表达式(包括lookbehinds)在VS2017中不起作用,.net,regex,visual-studio-2017,lookbehind,find-replace,.net,Regex,Visual Studio 2017,Lookbehind,Find Replace,在Visual Studio 2017中,我尝试将以下几行内容转变为: [AddressId] [int] NOT NULL, [CountryId] [int] NULL, [POBoxCountryId] [int] NULL, [Name] [nvarchar] (100) NULL, 为此: [AddressId] int NOT NULL, [CountryId] int NULL, [POBoxCountryId] int NULL, [Name] nvarchar (100) N

在Visual Studio 2017中,我尝试将以下几行内容转变为:

[AddressId] [int] NOT NULL,
[CountryId] [int] NULL,
[POBoxCountryId] [int] NULL,
[Name] [nvarchar] (100) NULL,
为此:

[AddressId] int NOT NULL,
[CountryId] int NULL,
[POBoxCountryId] int NULL,
[Name] nvarchar (100) NULL,
在我看来,正则表达式:
(?您可以使用

查找内容:
(\[\w+]\s+)\[\w+)

替换为
$1$2

详细信息

  • (\[\w+]\s+
    -第1组(
    $1
    ):
    [
    ,1+字字符,
    ]
    和1+空格
  • \[
    -a
    [
    字符
  • (\w+)
    -第2组(
    $2
    ):1+字字符
  • ]
    -一个
    ]
    字符

试试
(\[\w+]\s+)\[[w+]
并替换为
$1$2
@WiktorStribiżew它工作得很好,谢谢!这是否意味着我在VS中执行查找和替换时不应该使用lookbehinds?它们由.NET正则表达式引擎支持,不知道这里到底发生了什么。捕获组更安全。@WiktorStribiżew我将尝试创建一个错误报告给MS,看看它是否是专业的VS中的问题太糟糕了,它破坏了我一次完成一个大型正则表达式以一次完成多个操作的计划,我猜必须在链中应用不同的正则表达式。基于lookback的正则表达式匹配但不替换,这真的很奇怪。