So here's one of the simplest example what I found doesn't work in CS 5(1) and CS 6 (and I think in CS 3 and CS 4), but worked fine in CS 2:
Code: Select all
".1".replace(/(\.0)|(\.1)/g, '$1$2') // CS6 result is: undefined.1 but CS2 result is: .1
Code: Select all
".0".replace(/(\.0)|(\.1)/g, '$1$2') // CS6 result is: .0undefined but CS2 result is: .0
To make sure I'm right I checked how it works in some JavaScript editors. Everywhere it was like in CS2, and that is correct because that | character means OR, so when one condition isn't fulfiled then it's not displayed by undefined but only the second is called and vice versa.
If I wanted to fix above examples I had to write this:
Code: Select all
".1".replace(/(\.0)|(\.1)/g, '$1$2').replace(/undefined(\.\d)/g, '$1')
Code: Select all
".0".replace(/(\.0)|(\.1)/g, '$1$2').replace(/(\.\d)undefined/g, '$1')
It's only workaround, so someone doing it must be really careful if there are some
undefined words in the code he doesn't want to 'remove'
I tried all your regexp implement to my code but if I didn't miss anything any of them didn't solve the problem. Of course maybe there is some way, but from the above it seems it's a bug. My point wasn't to delete by RegExp all trailing zeros from after coma (1.000000 -> 1, 5.010000 -> 5.01, 0.100400 -> 0.1004). Like you see when there are only zeros after coma then only a digit without following coma stays as result. When there are some number over zero after coma then there stays leading number from before coma, a coma and all numbers from after coma (without last zeros). It's what my code was designed for. If there is:
Code: Select all
"DSC3.putDouble(sTT('warpPerspectiveOther'), 0.000000)" // it should give: 0 (no coma)
Code: Select all
"DSC3.putDouble(sTT('warpPerspectiveOther'), 0.0005200)" // it should give: 0.00052
Exapmlary snippet and CS2 result (global mode of regex):
Code: Select all
desc26.putUnitDouble( idHrzn, idPxl, 155.000000 ); // 155
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( idVrtc, idPxl, 134.000100 ); // 134.0001
var idPnt = charIDToTypeID( "Pnt " );
desc24.putObject( idFwd, idPnt, desc26 );
var idBwd = charIDToTypeID( "Bwd " );
var desc27 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idHrzn, idPxl, 151.003972 ); // 151,003972
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idVrtc, idPxl, 135.000010 ); // 135.00001
Exapmlary snippet and CS6 result (global mode of regex):
Code: Select all
desc26.putUnitDouble( idHrzn, idPxl, 155.000000 ); // 155undefined
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( idVrtc, idPxl, 134.000100 ); // *
var idPnt = charIDToTypeID( "Pnt " );
desc24.putObject( idFwd, idPnt, desc26 );
var idBwd = charIDToTypeID( "Bwd " );
var desc27 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idHrzn, idPxl, 151.003972 ); // *
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idVrtc, idPxl, 135.000010 );// *
// correct in case if first of two conditions isnt only for zero after comas, otherwise it would be somenumber.undefined
So 4 next lines including a number without: .000000, 00, '', 0 while for example in CS6 the result are mixed with
undefined