Regexp for changing only part of the found string
Hi!
I love regex but sometimes I get crazy trying to figure out things... I hope you can help me... here is the thing, I have to find all the ',' inside a large database dumb, but this ',' are only in this kind of mask: $ANYNUMBER-ANYQTD,ANYNUMBER-ANYQTD$ Actualy the $ is not the regex end of line special operator. (I had to use something like $ to avoid the " and ' inside text fields that were dumped). Here is the regex Im trying (Im in vim): %s/\$[0-9]+[,][0-9]+\$/I DONT KNOW HOW TO CHANGE ONLY THE DOT/g well... I couldnt understand why the above dont even match any line if I have lines like $0,01$, $100,14$ and want they to became $0.01$, $100.14$ and so on... thks! |
Please post a larger sample of the file that you are trying to modify.
Will there be other commas in the file (that need to stay as commas)? If not why not just try (within vi) :1,$ s/,/./g |
Quote:
|
I think you meant, from within vi:
Code:
:1,$ s/\([0-9]\),\([0-9]\)/\1.\2/g Code:
sed -i 's/\([0-9]\),\([0-9]\)/\1.\2/g' file |
Hey, thanks! The SED example worked fine here, but the VI example didnt, althought it worked was not the right way, like describle in the mask and like the way sed did...
but thanks for the both [ ]'s |
All times are GMT -5. The time now is 02:26 AM. |