You can use this (should work with notepad++):
search: (?>[^$]+|\$(?!\d{1,2}\.\d{2}))*(\$\d{1,2}\.\d{2})
replace: $1+
(or search: .*?(\$\d{1,2}\.\d{2})
)
and you remove by hand the last +
Question
I have a messy list and I'm trying to get rid of everything except prices, which do have a dollar sign $ in front.
They don't have the same number of digits, though. Some are "$X.XX" and others are "$XX.XX"
And if possible, I'd like to be able to insert a "+" in between the prices, so it'll look something like "$X.XX+$XX.XX+..."
I tried searching, but the solutions didn't work for me (they used the pound symbol though, which might have needed a different query)
Solution
You can use this (should work with notepad++):
search: (?>[^$]+|\$(?!\d{1,2}\.\d{2}))*(\$\d{1,2}\.\d{2})
replace: $1+
(or search: .*?(\$\d{1,2}\.\d{2})
)
and you remove by hand the last +
OTHER TIPS
The regex to match your prices would be
\$\d+\.\d+
where \$
is a dollar sign (remember you need to escape it because just $
means end of string, \d+
means at least one digit, \.
a dot (again, escape because .
means any character)
This will match to
$1.2
, $24.67
etc.
In Sublime Text, you could then remove everything else by using Find-Replace
:
find: .*(\$\d*\.\d*).*
replace: $1
Example
product1 $14.22 categoryA
product2 $5.2 categoryA
product3 $0.2456 categoryB
would become
$14.22
$5.2
$0.2456