Parse adduct

Description

This function parses adducts

Usage

parse_adduct(
  adduct_string,
  regex = "\\[(\\d*)M(?![a-z])(\\d*)([+-][\\w\\d].*)?.*\\](\\d*)([+-])?"
)

Arguments

adduct_string Adduct to be parsed
regex Regex used for parsing

Value

Parsed elements from adduct

Examples

library("tima")

parse_adduct("[M+H]+")
parse_adduct("[2M1-C6H12O6 (hexose)+NaCl+H]2+")