File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
tool/formula/src/main/java/org/openscience/cdk/tools/manipulator Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1234,6 +1234,16 @@ public static String simplifyMolecularFormula(String formula) {
12341234 * @return Formula with the correction
12351235 */
12361236 private static String breakExtractor (String formula ) {
1237+ /* Regex explanation:
1238+ * (.*) Takes everything from before the formula (Group 1)
1239+ * \( Matches the open bracket "(" (No group)
1240+ * ([^(]+?) Matches everything that isn't an opening
1241+ * bracket (The formula inside the inner most bracket) (Group 2)
1242+ * \) Matches a closing bracket (No group)
1243+ * ([0-9]*) Matches the multiplier number, if any (Group 3)
1244+ * (.*) Takes everything from after the formula to remove the
1245+ * parenthesis from (Group 4)
1246+ */
12371247 Pattern pattern = Pattern .compile ("(.*)\\ (([^(]+?)\\ )([0-9]*)(.*)" );
12381248
12391249 while (formula .contains ("(" )) {
You can’t perform that action at this time.
0 commit comments