I have the following string with line breaks \r\n:
var myString = "DTSTART:20161009T160000Z
DTEND:20161009T170000Z
RRULE:FREQ=DAILY;UNTIL=20161015T000000Z;INTERVAL=1;BYDAY=SU,MO,TU,WE,TH,FR,SA
EXDATE:20161009T160000Z"
I want to extract the rrule as follows:
FREQ=DAILY;UNTIL=20161015T000000Z;INTERVAL=1;BYDAY=SU,MO,TU,WE,TH,FR,SA
Currently I can achieve this by doing the following
var subStr = myString.match("RRULE:(.*)\r\n");
alert(subStr[1]);
Sometimes the EXDATE line doesn't exist in which case there is no \r\n after the RRULE line. Anyone know of a cleaner way to do it without having to output using an array index?
/RRULE:(.*)/should be enough, or this looks more precise -/^\s*RRULE:(.*)/m