英文:
Notepad++ | Regex Find/replace values
问题
Sure, here's the translated portion:
我有以下格式的数据:
('A','b',*null*,'c')
('D',null,'*e,f*','g')
('1','2','*4,5,6*',null)
我大约有300行类似的数据。
需要将所有斜体的数据更改为'N'
,这是第三个字段。
所有其余数据都需要保持不变。
我是notepad++
的新手。
是否有办法使用正则表达式来实现??
在Excel中尝试了文本分列,但没有成功。
英文:
I have data in the below format
(‘A’,’ b’,*null*,’c’)
(‘D’,null,’*e,f*’,’g’)
(‘1’,’2’,’*4,5,6*’,null)
I have around 300 rows of similar data..
required to change all the data in italics to ‘N’
, which is the third field..
all the remaining data need to be as it is.
I am new to notepad++
.
Is there a way we can do using regex??
Tried txt to columns in excel, but didn’t work
答案1
得分: 2
- <kbd>Ctrl</kbd>+<kbd>H</kbd>
- 查找内容:
\((?:'.+?'|null),(?:'.+?'|null),\K(?:'.+?'|null)
- 替换为:
'N'
- 选中 匹配大小写
- 选中 循环查找
- 选择 正则表达式
- 取消选中
. 匹配换行符
- <kbd>全部替换</kbd>
英文:
- <kbd>Ctrl</kbd>+<kbd>H</kbd>
- Find what:
\((?:'.+?'|null),(?:'.+?'|null),\K(?:'.+?'|null)
- Replace with:
'N'
- TICK Match case
- TICK Wrap around
- SELECT Regular expression
- UNTICK
. matches newline
- <kbd>Replace all</kbd>
Explanation:
\( # opening parenthesis
(?:'.+?'|null) # non capture group, 1 or more any character between single quotes OR literally "null"
, # a comma
(?:'.+?'|null) # non capture group, 1 or more any character between single quotes OR literally "null"
, # a comma
\K # forget all we have seen until this position
(?:'.+?'|null) # non capture group, 1 or more any character between single quotes OR literally "null"
Screenshot (before):
Screenshot (after):
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论