Reputation: 21
I am trying to replace some numbers with - signs into some other format using notepad++
For example
-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 {
Thanks
Upvotes: 2
Views: 49
Reputation: 921
Use a conditional replacement in 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 {
The named group is optional i.e. \2?{1}}:{
or even \2?1}:{
works the same.
Remember to modify the regex in Find what to wholy match your format.
Upvotes: 2