1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
295 views
by brandon-w-8204 (34.1k points)
I have one of the following strings:
4ml
0.5ml
6mg

How can I split the dose and the dose Unit so it can be placed in separate fields.

1 Answer

0 votes

Here is a sample code to split them up:

var pattern = java.util.regex.Pattern.compile("^([\\d,.]+)([A-z]+)");
            var matcher = pattern.matcher(combinedDose);
            var dose;
            var doseUnits;
            if (matcher.find()) {
               dose = matcher.group(1);
               doseUnits = matcher.group(2);
            }
 

by brandon-w-8204 (34.1k points)
...