Removing Timestamps from Yahoo News Titles
Yahoo News article titles include timestamps in Japanese format that need to be removed.
Timestamp Format
Titles contain timestamps like:
12/27(土) 10:45
Pattern: MM/DD(DayOfWeek) HH:MM
Where DayOfWeek is one of: 月, 火, 水, 木, 金, 土, 日
Removal Method
Use regex to strip the timestamp:
let title = "AI隆盛 アニメ業界の権利どう守る 12/27(土) 10:45";
// Remove timestamp pattern
title = title.replace(/\d{1,2}\/\d{1,2}\([月火水木金土日]\)\s*\d{1,2}:\d{2}$/, '').trim();
console.log(title); // "AI隆盛 アニメ業界の権利どう守る"
Also Remove Video Duration
Video articles may have duration prefix:
// Remove video duration (format: 0:59)
title = title.replace(/^\d{1,2}:\d{2}/, '').trim();
Complete Cleanup Function
function cleanYahooNewsTitle(title: string): string {
let cleaned = title;
// Remove video duration prefix
cleaned = cleaned.replace(/^\d{1,2}:\d{2}/, '').trim();
// Remove timestamp suffix
cleaned = cleaned.replace(/\d{1,2}\/\d{1,2}\([月火水木金土日]\)\s*\d{1,2}:\d{2}$/, '').trim();
return cleaned;
}
// Usage
const raw = "0:59 AI隆盛 アニメ業界の権利どう守る 12/27(土) 10:45";
const clean = cleanYahooNewsTitle(raw);
console.log(clean); // "AI隆盛 アニメ業界の権利どう守る"
Regex Breakdown
^\d{1,2}:\d{2}- Matches duration at start (e.g., "0:59")\d{1,2}\/\d{1,2}- Matches date (e.g., "12/27")\([月火水木金土日]\)- Matches day of week in parentheses\s*\d{1,2}:\d{2}$- Matches time at end (e.g., " 10:45")