const regex = /^DTSTART:(.+)$/mg;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^DTSTART:(.+)$', 'mg')
const str = `BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:1. Bundesliga
X-WR-TIMEZONE:Europe/Berlin
X-WR-CALDESC:iCal-Spielplan mit allen Spielen der 1. Bundesliga 2013-2014 -
gratis abonnieren!
BEGIN:VEVENT
DTSTART:20150226T200500Z
DTEND:20150226T220500Z
DTSTAMP:20150227T073355Z
UID:jmgapu2jbqhsesbpjlfc495c90@google.com
CREATED:20141216T183608Z
DESCRIPTION:Europa League\\, Zw.\\n\\nhttp://www.fussball-spielplan.de
LAST-MODIFIED:20150226T221219Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:Sporting Lissabon - VfL Wolfsburg (0:0)
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART:20150226T180000Z
DTEND:20150226T200000Z
DTSTAMP:20150227T073355Z
UID:uorcsvdsc24f37frgm36f3sfak@google.com
CREATED:20141216T164808Z
DESCRIPTION:Europa League\\, Zw.\\n\\nhttp://www.fussball-spielplan.de
LAST-MODIFIED:20150226T200016Z
LOCATION:Borussia-Park\\, Mönchengladbach
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:Bor. Mönchengladbach - FC Sevilla (2:3)
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART:20150225T194500Z
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions