The string to search for a CAS number
The first valid CAS number found, or undefined
findCAS('Example of a valid cas: 1234-56-6..') // Returns '1234-56-6'
findCAS('and 50-00-0 is another valid cas #') // Returns '50-00-0'
findCAS('Example of an invalid cas: 1232-56-6..') // Returns undefined
findCAS('and 50-00-1 is another valid cas #') // Returns undefined
export function findCAS(data: string): CAS<string> | void {
const regex = RegExp(CAS_REGEX.source, "g");
const match = data.match(regex);
if (match && isCAS(match[0])) return match[0];
}
Searches for a valid CAS number within a string. Returns the first valid CAS number found, or undefined if none are found.