用于包围包含字符串“;@tab;@tab;@tab;”的文本的正则表达式带引号
RegEx to surround text that contains the string ";@tab;@tab;@tab;" with quotes
我正在尝试创建一个 PCRE RegEx surrounds 字符串,其中包含字符串 ;@tab;@tab;@tab;
和引号 ("
).输入由多行文本组成,其中包含 1 个或多个用 制表符 分隔的列。必须用引号 ("
) 括起来的字符串可以位于行首、行尾或行中间。一行可以包含 0 个或更多必须包围的字符串。
示例:
1 some text with spaces
1 some text with spaces anotherValue
1 some text with spaces anotherValue 3452.2
val_so some text with spaces anotherValue 3452.2
val_so space some text with spaces anotherValue 3452.2
some text with spaces anotherValue 3 other text with spaces
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs and spaces anotherValue
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with spaces anotherValue 3452.2
val_so some;t@b;t@b;t@b;text with spaces and;t@b;t@b;t@b; tabs anotherValue 3452.2
val_so space some text with;t@b;t@b;t@b; spaces amd tabs anotherValue 3452.2
some text;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
;t@b;t@b;t@b;;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
必须变成
1 some text with spaces
1 some text with spaces anotherValue
1 some text with spaces anotherValue 3452.2
val_so some text with spaces anotherValue 3452.2
val_so space some text with spaces anotherValue 3452.2
some text with spaces anotherValue 3 other text with spaces
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs"
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs and spaces" anotherValue
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with spaces" anotherValue 3452.2
val_so "some;t@b;t@b;t@b;text with spaces and;t@b;t@b;t@b; tabs" anotherValue 3452.2
val_so space "some text with;t@b;t@b;t@b; spaces amd tabs" anotherValue 3452.2
"some text;t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
";t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
";t@b;t@b;t@b;;t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
我尝试了以下 PCRE RegEx search RegEx: \b(([^\t]+);t@b;([^\t]+))\b
with g
flag replace RegEx: ""
但它匹配多行的字符串(匹配不会在行尾停止)但我希望每一行都单独匹配。
由于数据是用制表符分隔的,不想跨行,可以通过在取反符中加一个换行来排除匹配class.
您可以省略单词边界,因为它不会匹配 ;
开头和结尾的 ;t@b;t@b;t@b;
您不需要捕获组,因为您想要替换双引号之间的整个匹配项。
[^\t\r\n]+;t@b;[^\t\r\n]+
看到一个regex demo
在替换中使用双引号之间的整个匹配。
"[=11=]"
我正在尝试创建一个 PCRE RegEx surrounds 字符串,其中包含字符串 ;@tab;@tab;@tab;
和引号 ("
).输入由多行文本组成,其中包含 1 个或多个用 制表符 分隔的列。必须用引号 ("
) 括起来的字符串可以位于行首、行尾或行中间。一行可以包含 0 个或更多必须包围的字符串。
示例:
1 some text with spaces
1 some text with spaces anotherValue
1 some text with spaces anotherValue 3452.2
val_so some text with spaces anotherValue 3452.2
val_so space some text with spaces anotherValue 3452.2
some text with spaces anotherValue 3 other text with spaces
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs and spaces anotherValue
1 some;t@b;t@b;t@b;text;t@b;t@b;t@b;with spaces anotherValue 3452.2
val_so some;t@b;t@b;t@b;text with spaces and;t@b;t@b;t@b; tabs anotherValue 3452.2
val_so space some text with;t@b;t@b;t@b; spaces amd tabs anotherValue 3452.2
some text;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
;t@b;t@b;t@b;;t@b;t@b;t@b; with spaces anotherValue 3 other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs
必须变成
1 some text with spaces
1 some text with spaces anotherValue
1 some text with spaces anotherValue 3452.2
val_so some text with spaces anotherValue 3452.2
val_so space some text with spaces anotherValue 3452.2
some text with spaces anotherValue 3 other text with spaces
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs"
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with tabs and spaces" anotherValue
1 "some;t@b;t@b;t@b;text;t@b;t@b;t@b;with spaces" anotherValue 3452.2
val_so "some;t@b;t@b;t@b;text with spaces and;t@b;t@b;t@b; tabs" anotherValue 3452.2
val_so space "some text with;t@b;t@b;t@b; spaces amd tabs" anotherValue 3452.2
"some text;t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
";t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
";t@b;t@b;t@b;;t@b;t@b;t@b; with spaces" anotherValue 3 "other text;t@b;t@b;t@b;with spaces;t@b;t@b;t@b;and tabs"
我尝试了以下 PCRE RegEx search RegEx: \b(([^\t]+);t@b;([^\t]+))\b
with g
flag replace RegEx: ""
但它匹配多行的字符串(匹配不会在行尾停止)但我希望每一行都单独匹配。
由于数据是用制表符分隔的,不想跨行,可以通过在取反符中加一个换行来排除匹配class.
您可以省略单词边界,因为它不会匹配 ;
开头和结尾的 ;t@b;t@b;t@b;
您不需要捕获组,因为您想要替换双引号之间的整个匹配项。
[^\t\r\n]+;t@b;[^\t\r\n]+
看到一个regex demo
在替换中使用双引号之间的整个匹配。
"[=11=]"