简体   繁体   English

在记事本中用正则表达式替换

[英]Replace with regular expression in notepad++

I have a dropdown list which displayed in page source: 我有一个下拉列表,显示在页面源中:

<option value="2" >39</option>
<option value="3" >40</option>
<option value="4" >40.5</option>
<option value="5" >41.5</option>
<option value="6" >42</option>

After searching I find the solution to replace the option tags: 搜索之后,我找到了替换选项标签的解决方案:

Find: <option[^>]*>([^<]*)</option> 查找: <option[^>]*>([^<]*)</option>

replace with \\1, which result in: 替换为\\ 1,结果为:

39
40
40.5
41.5
42

But I also want to remove all the white spaces and new lines, and replace "." 但我也想删除所有空白和换行,并替换为“。” with "_", so the output should be 39,40,40_5,41_5,42 Thanks. 与“ _”,因此输出应为39,40,40_5,41_5,42谢谢。

I can't see a way to do the job with an unique regex, but in two passes: 我看不到使用唯一的正则表达式来完成这项工作的方法,但是有两个过程:

First pass: 第一遍:
Find what: <option[^>]*>([^<]*)</option>\\R 查找内容: <option[^>]*>([^<]*)</option>\\R
Replace with: $1, 替换为: $1,

Second pass: 第二遍:
Find what: \\. 查找内容: \\.
Replace with: _ 替换为: _

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM