|
@@ -35,4 +35,18 @@ export function Inspect(value: any): void {
|
|
|
*/
|
|
|
export function DeepClone(value: any): any {
|
|
|
return JSON.parse(JSON.stringify(value));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Extracts all numbers from a string
|
|
|
+ *
|
|
|
+ * If there were no numbers in the string, then an empty array is returned.
|
|
|
+ *
|
|
|
+ * Numbers in the output are in the order they appeared in in the input
|
|
|
+ *
|
|
|
+ * @param {string} str A string
|
|
|
+ * @returns {number[]} An array of numbers
|
|
|
+ */
|
|
|
+export function ExtractNumbers(str: string): number[] {
|
|
|
+ return str.split(/\D/).filter((n) => n.length).map((n) => Number(n));
|
|
|
}
|