replace - 使用Notepad++将数字替换为某种格式

标签 replace numbers find notepad++

我正在尝试使用 Notepad++ 将一些带有 - 符号的数字替换为其他格式

例如

-4399.10 changed to 439910}
4399.10  changed to 439919{
-2303.29 changed to 230329}
2303.29  changed to 230329{

all negative signs will be changed to } symbol from right
all positive will be replaced with { 

谢谢

最佳答案

在 Notepad++ 中使用条件替换

Find what :(?<negative>-)?(\d+(\.\d+)?)
Replace with :\2?{negative}}:{

\2?{negative}}:{
\2                 the captured number without sign in group 2
  ?{negative}      if group negative (negative sign) is matched
             }       character }
              :    else
               {     character {

命名组是可选的,即 \2?{1}}:{甚至\2?1}:{工作原理是一样的。
请记住修改“查找内容”中的正则表达式以完全匹配您的格式。

关于replace - 使用Notepad++将数字替换为某种格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40209923/

相关文章:

python - 使用 Pandas 动态替换其他列中的值

c# - 四舍五入到 10

bash - 我如何grep反引号?

linux - 在查找命令的路径中使用带有 ~ 的符号链接(symbolic link)

php - YouTube链接并获取方法

c# - 如何替换 LinkedList 中的元素?

javascript - 替换正则表达式

Python 反转数字

java - DecimalFormat,如何通过模式设置最大整数位数?

PHP 锂 : Filtering an existent DocumentSet and get first Match