I am trying to write a method that converts from engineering notation to double. The case I have now is very special! I mean I am not going to look for powers like “Mega, Giga and …” I am just looking for floating points.
Some valid examples of my Case are:
1.0 A should be 1
1.0064 mA or 1.0064 Ma should be 0.0010064 Note that I count both M and m as mili…that can be achived using ToLower() method. and that A or a counts as Ampere for current.
I have the same case for Voltage, so in that user can enter V or v instead.
again some valid cases:
256ma 366 m a 10.665 uA
So at the end before I pass this string to my converting method, I do text.ToLower().Remove(" ", string.Empty); this will hopefully leave me with a easy string to work on.
Now the second step is to split numbers from characters:
10.665ua should result in 10.665 and ua so then I can check for first character of ua against a list of allowed strings and find the power factor.
private List<string> AllowedCurrentStrings = new List<string>() { "a", "ma", "m", "ua", "u", "na", "n", "pa", "p" };
So I am looking for your help. first I need to know how to split numbers from characters and then group the characters into a string (Or do I need to do the later one?)
Or if you think my approach is not good, it would be nice to hear a better one from you!
You could try this: