LeetCodeNumber of Segments in a StringNumber of Segments in a StringEasyStringSolution export function countSegments(s: string): number { const matched = s.match(/([^ ]+)/g); return matched ? matched.length : 0; }LeetCodeNumber of Segments in a Stringhttps://leetcode.com/problems/number-of-segments-in-a-string