Regex 记事本++;正则表达式搜索具有特定结构的行的一部分
我只需要一个正则表达式在SQL中提取Regex 记事本++;正则表达式搜索具有特定结构的行的一部分,regex,notepad++,Regex,Notepad++,我只需要一个正则表达式在SQL中提取(XX,3,57,1,XX,“提取的内容”) 我需要一个查找/替换代码来转换这样的代码 (808, 3, 43, 0, 82, 'coroa-flores-velorio-cemiterio-araca-sp'), (809, 3, 57, 1, 82, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-araca-sp.html'
(XX,3,57,1,XX,“提取的内容”)
我需要一个查找/替换代码来转换这样的代码
(808, 3, 43, 0, 82, 'coroa-flores-velorio-cemiterio-araca-sp'),
(809, 3, 57, 1, 82, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-araca-sp.html'),
(810, 3, 57, 0, 82, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-araca-sp.html'),
(814, 3, 41, 0, 83, 'Coroa de Flores Cemitério Baeta Neves - São Bernardo'),
(815, 3, 43, 0, 83, 'coroa-flores-velorio-cemiterio-baeta-neves'),
(816, 3, 46, 0, 83, 'Coroa de Flores Velório Cemitério Baeta Neves - Cesta e Flor'),
(817, 3, 49, 0, 83, 'PRODUCTS'),
(818, 3, 58, 0, 83, NULL),
(819, 3, 61, 0, 83, NULL),
(820, 3, 57, 1, 83, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-baeta-neves.html'),
(821, 3, 57, 0, 83, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-baeta-neves.html'),
(822, 3, 41, 0, 84, 'Coroa de Flores Cemitério Camilópolis - Santo André'),
(823, 3, 43, 0, 84, 'coroa-flores-velorio-cemiterio-camilopolis-santo-andre'),
(824, 3, 46, 0, 84, 'Coroa Flores Velório Camilópolis Santo André - Cesta e Flor'),
(825, 3, 49, 0, 84, 'PRODUCTS'),
(826, 3, 58, 0, 84, NULL),
(827, 3, 61, 0, 84, NULL),
(828, 3, 57, 1, 84, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-camilopolis-santo-andre.html'),
(829, 3, 57, 0, 84, 'coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-camilopolis-santo-andre.html'),
(830, 3, 41, 0, 85, 'Coroa de Flores Velório Parque da Cantareira - São Paulo'),
(831, 3, 43, 0, 85, 'coroa-flores-velorio-parque-cantareira-sp'),
(832, 3, 46, 0, 85, 'Coroa de Flores Velório Pq da Cantareira SP - Cesta e Flor'),
(833, 3, 49, 0, 85, 'PRODUCTS'),
(834, 3, 58, 0, 85, NULL),
(835, 3, 61, 0, 85, NULL),
在某种程度上
coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-veenter code herelorio-cemiterio-araca-sp.html
coroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-baeta-neves.html
oroas-flores-para-velorio/coroa-flores-velorio-sao-paulo/coroa-flores-velorio-cemiterio-camilopolis-santo-andre.html
查找需要搜索具有该结构的内容
(???, 3, 57, 1, ???, 'CONTENT')
而替换需要
CONTENT
有什么想法吗?- Ctrl+H
- 查找内容:
^\(\d+,3,57,1,\d+,“([^']+)”\),$^.+$
- 替换为:
$1
- 全部替换
^ : begining of line
\( : an open parenthesis
\d+, 3, 57, 1, \d+, : some digits, then "3, 57, 1" then some digits
' : single quote
([^']+) : group 1, every thing that is not a quote
' : single quote
\), : close parenthesis and a comma
$ : end of line
| : OR
^ : begining of line
.+ : 1 or more any character
$ : end of line
$1 : group 1, it will replace lines that don't match with empty string.
更换:
^ : begining of line
\( : an open parenthesis
\d+, 3, 57, 1, \d+, : some digits, then "3, 57, 1" then some digits
' : single quote
([^']+) : group 1, every thing that is not a quote
' : single quote
\), : close parenthesis and a comma
$ : end of line
| : OR
^ : begining of line
.+ : 1 or more any character
$ : end of line
$1 : group 1, it will replace lines that don't match with empty string.
- Ctrl+H
- 查找内容:
^\(\d+,3,57,1,\d+,“([^']+)”\),$^.+$
- 替换为:
$1
- 全部替换
^ : begining of line
\( : an open parenthesis
\d+, 3, 57, 1, \d+, : some digits, then "3, 57, 1" then some digits
' : single quote
([^']+) : group 1, every thing that is not a quote
' : single quote
\), : close parenthesis and a comma
$ : end of line
| : OR
^ : begining of line
.+ : 1 or more any character
$ : end of line
$1 : group 1, it will replace lines that don't match with empty string.
更换:
^ : begining of line
\( : an open parenthesis
\d+, 3, 57, 1, \d+, : some digits, then "3, 57, 1" then some digits
' : single quote
([^']+) : group 1, every thing that is not a quote
' : single quote
\), : close parenthesis and a comma
$ : end of line
| : OR
^ : begining of line
.+ : 1 or more any character
$ : end of line
$1 : group 1, it will replace lines that don't match with empty string.
是的,你可以使用正则表达式。一个简单的方法,查找
\((?:[^,)]*,){5}'([^')]*)
,替换$1
我没有记事本++,但正则表达式可以是:\(\d{3},3,57,1,\d{2},\'(.*)\),
并替换为$1
,具体取决于你的版本。伊曼纽尔,我可以提供帮助,但请分享你的尝试。了解您用于避免对需求产生任何误解的内容是很重要的。@sln:这将匹配所有行,OP只需要那些包含3,57,1
的行。是的,您可以使用正则表达式。简单的方法是查找\(?:[^,)]*,){5}'([^')]*)
,替换$1
我没有记事本++,但是正则表达式可以是:\(\d{3},3,57,1,\d{2},\'(.*)\),
并替换为$1
或\1
,具体取决于您的版本。伊曼纽尔,我可以帮忙,但请分享您的尝试。了解您使用了什么来避免对需求的任何误解是很重要的。@sln:这将匹配所有行,OP只需要那些包含3,57,1
的行。非常感谢您的帮助,并解释了代码,但不幸的是,在我的情况下没有起作用。我没有投反对票。@伊曼纽尔:什么不起作用?你得到了什么?我用NPP7.2.2进行了测试,它是有效的。您是否检查了正则表达式而没有检查。匹配换行符
?您从哪里学到的?我真的需要这个,我怎样才能说服你的答案?它显示了以下信息:感谢您的反馈!声誉低于15的人所投的票将被记录,但不会改变公开显示的帖子分数。但是,真的谢谢你@丹:你的案子比这个难多了。我会看一看的。真的非常感谢,非常感谢你的帮助,并解释了代码,但不幸的是,在我的情况下没有工作。我没有投反对票。@伊曼纽尔:什么不起作用?你得到了什么?我用NPP7.2.2进行了测试,它是有效的。您是否检查了正则表达式而没有检查。匹配换行符
?您从哪里学到的?我真的需要这个,我怎样才能说服你的答案?它显示了以下信息:感谢您的反馈!声誉低于15的人所投的票将被记录,但不会改变公开显示的帖子分数。但是,真的谢谢你@丹:你的案子比这个难多了。我来看看。