UNPKG

resume-parser-mcp

Version:

To install dependencies:

19 lines (16 loc) 707 B
export function extractName(text: string) { // 简单实现:假设姓名在文本开头,且是最长的单词组合 const lines = text.split('\n').filter((line) => line.trim().length > 0); if (lines.length === 0) return null; // 尝试匹配可能的姓名行(通常是第一行或包含"姓名"关键词的行) const nameLine = lines.find( (line) => line.includes('姓名') || line.includes('Name') || // 假设姓名是首行且长度适中 (lines.indexOf(line) === 0 && line.length > 3 && line.length < 50) ) || lines[0]; // 移除可能的关键词 return nameLine.replace(/姓名|Name|:|:|\/|\(/g, '').trim(); }