I have a string in which the data is getting loaded in this format. “float;#123456.0300000” from which i need to extract only 123456.03 and trim all other starting and ending characters. May be it is very basic that i am missing, please let me know how can i do that. Thanks.
Share
If the format is always
float;#followed by the bit you want, then it’s fairly simple:But you really need to be confident in the format – that there won’t be anything else you need to remove, etc.
In particular:
+valid?You may well want to use a regular expression if you need anything more complicated than the code above, but you’ll really want to know as much as you can about your possible inputs before going much further. (I’d strongly recommend writing unit tests for every form of input you can think of.)