Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to modify RegularExpression to Parse vCard/vCalendar to allow a particular field type?
    text
    copied!<p>I have an vCard application that needs to read vCard Data, and have found a RegularExpression which gets the FieldName, Encoding and FieldValue from the file, here it is below:</p> <pre><code>^(?&lt;FIELDNAME&gt;[\w-]{1,})(?:(?:;?)(?:ENCODING=(?&lt;ENC&gt;[^:;]*)|CHARSET=(?&lt;CHARSET&gt;[^:;]*))){0,2}:(?:(?&lt;CONTENT&gt;(?:[^\r\n]*=\r\n){1,}[^\r\n]*)|(?&lt;CONTENT&gt;[^\r\n]*)) </code></pre> <p>This Regular Expression Reads these kind of values fine:</p> <pre><code>ORG:Company FN;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:RoguePlanetoid </code></pre> <p>However I want it to read these values also</p> <pre><code>TEL;WORK;VOICE:0200 0000000 </code></pre> <p>Without skipping them. How can I modify the RegularExpression so TEL;WORK;VOICE ends up as part of the "FIELDNAME" and 0200 0000000 is part of the "CONTENT".</p> <p>I am unfamiliar with complex RegularExpressions and cannot figure out how to modify it, there is a regular expression that gets these:</p> <pre><code>^(?:TEL)([^:]*):(?&lt;TEL&gt;[^\r\n]*) </code></pre> <p>However it only gets the FieldName as "TEL" and I need the whole value for this so I can tell the numbers apart in my application.</p> <hr> <p>If possible the Regular Expression would read the WORK and VOICE elements also like the CHARSET and ENCODING in the current regular expression, so they can treated like an Attribute and Type for example, however anything which allows the Regular Expression to read the whole TEL;WORK;VOICE as the FIELDNAME will be fine.</p> <hr> <p><strong>Edit</strong></p> <pre><code>^(?&lt;FIELDNAME&gt;[^:]{1,})(?:(?:;?)(?:ENCODING=(?&lt;ENC&gt;[^:;]*)|CHARSET=(?&lt;CHARSET&gt;[^:;]*))){0,2}:(?:(?&lt;CONTENT&gt;(?:[^\r\n]*=\r\n){1,}[^\r\n]*)|(?&lt;CONTENT&gt;[^\r\n]*)) </code></pre> <p>Reads up to the first Colon which covers the Whole FieldName, however it would be nice to store each SemiColon Element in a seperate item such as ATTRIBUTE or TYPE.</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