Question

So I'm trying to return every Event inside a icr file (calender file based on vCalendar [.vcs]) with Regex (inside AutoIt). So an event inside a icr file starts with the line BEGIN:VEVENT and ends with END:VEVENT. I read the file to variable x and replace every new line in x with '[n', so the RegEx looks something like (BEGIN:VEVENT\[n(?:\[n|[^\[]+)+END:VEVENT) (begin, a number greater 0 of newlines or chars unequal to [ and end)
This works fine when I insert something like 'foo[nBEGIN:VEVENT[ndata[nEND:VEVENT[nbar' but here comes the problem: I have two teststrings, upper one is returning a result, lower one isnt:

1[nBEGIN:VEVENT[ndata1[nEND:VEVENT[nxxxxxxxxxxx[BEGIN:VEVENT[ndata2[nEND:VEVENT 1[nBEGIN:VEVENT[ndata1[nEND:VEVENT[nxxxxxxxxxxxx[BEGIN:VEVENT[ndata2[nEND:VEVENT

You can test it for yourself at regex101.com

Was it helpful?

Solution 2

For everyone too lazy to take a look at the comments: this is the solution l'L'l came up with, with some tweaking by me:

(?:BEGIN:VEVENT)\[n(.+?)\[.(?:END:VEVENT)

OTHER TIPS

Try using this pattern, it will not limit what is inside the VEVENT[n:

(BEGIN:VEVENT\[ndata(?:\[n|[^\[])+END:VEVENT)

Example: http://regex101.com/r/zL2sK1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top