Note that there are some explanatory texts on larger screens.

plurals
  1. PORead Parameters out of icalendar file with JS
    text
    copied!<p>I'd like to read several parameters out of an iCalendar file with JavaScript.</p> <p>The file input looks like:</p> <blockquote> <p>BEGIN:VEVENT DTSTART:20121127T190000Z DTEND:20121127T210000Z DTSTAMP:20121130T185808Z UID:q4sbrtajjol1hlpiijpho5jac0@google.com CREATED:20121102T191519Z DESCRIPTION:1. Bundesliga\, 14. Spieltag \n\nhttp://www.fussball-spielplan. info LAST-MODIFIED:20121127T211459Z LOCATION:Commerzbank-Arena\, Frankfurt SEQUENCE:10 STATUS:CONFIRMED SUMMARY:Eintracht Frankfurt - 1. FSV Mainz 05 (1:3) TRANSP:TRANSPARENT END:VEVENT</p> </blockquote> <p>The parameter tags are:</p> <pre><code>DTSTART: DTEND: DTSTAMP: UID: CREATED: DESCRIPTION: LAST-MODIFIED: LOCATION: STATUS: SUMMARY: TRANSP: </code></pre> <p>I want to read the values behind these parameters. The length of the values are mostly variable.</p> <p>Using a <code>RegExp</code> is quite hard as I currently don't know what to set as a delimiter. <code>"\n"</code> doesn't work as all text parts are separated by a space. But if I use the space delimiter <code>"\s"</code> it will separate after each word, which is not the wanted result especially for the parameter <code>DESCRIPTION:</code> with a longer text included.</p> <p>My source code looks currently like this:</p> <pre><code>file_reader.onload = function (evt) { document.getElementById("filedrag").textContent = evt.target.result; Output( "&lt;p&gt;File information: &lt;strong&gt;" + file.name + "&lt;/strong&gt; type: &lt;strong&gt;" + file.type + "&lt;/strong&gt; size: &lt;strong&gt;" + file.size + "&lt;/strong&gt; bytes&lt;/p&gt;"); var regexp = new RegExp("/DTSTART:(.*?)\s/", "g"); var file_content = evt.target.result; var match, matches = []; while ((match = regexp.exec(file_content)) != null) { matches.push(match.index); } alert(matches); } </code></pre> <p>Any ideas, how I can achieve my idea?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload