Dji Posted April 17, 2014 Report Share Posted April 17, 2014 Hi, I would like to add trailing zeros of a variable when I encounter a version number without it: Examples: if initial version 5.57 -> version is 5.57 but : if initial version 5.8 -> version would be 5.80 and not 5.8 In such cases I usually use regular expression replacements but the following regular regexpression syntaxes does not works unfortunatey... {version:regexreplace:^(\d+)\.(\d)(?!\d)$:$1.$20} -> result is 5.$20 can't work of course, group 20 is unknown {version:regexreplace:^(\d+)\.(\d)(?!\d)$:$1.$2\0} -> result is 5.8\0 escape character doesn't work as well {version:regexreplace:^(\d+)\.(?<first>\d)(?!\d)$:$1.${first}0} -> result is 5.${first0} group name is unkown ! {version:regexreplace:^(\d+)\.(?<first>\d)(?!\d)$:$1.${first\}0} -> result is 5.${first}0 group name is unkown even using escape character ! Help required, thanks ! Link to comment Share on other sites More sharing options...
Electrosokk Posted April 19, 2014 Report Share Posted April 19, 2014 I tried your first regex, and it worked fine for me. Are you using the latest Ketarin beta (1.7.0 b2) ? Try the following regex, and see if its work: {version:regexreplace:^\d+\.\d$:$00} If still not working, than create a textual variable with the name "version1" : {version:regexreplace:^\d+\.\d$:$0#} And now you can use replace to add the zero: {version1:replace:#:0} Link to comment Share on other sites More sharing options...
Dji Posted April 29, 2014 Author Report Share Posted April 29, 2014 Year, I got it ! Thanks for your suggestions I finally used the following regex: {version:regexreplace:^\d+(\.\d+)*\.\d$:$00} Again thanks ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now