Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a regex I used a while back that also deals with escaped quotes <strong>AND escaped delimiters</strong>. It's probably overkill for your requirements (counting columns) but perhaps it'll help you or someone else in the future with their parsing.</p> <pre><code>(?&lt;=^|(?&lt;!\\)\|)(\".*?(?&lt;=[^\\])\"|.*?(?&lt;!\\(?=\|))(?=")?|)(?=\||$) and broken down as: (?&lt;=^|(?&lt;!\\)\|) // look behind to make sure the token starts with the start anchor (first token) or a delimiter (but not an escaped delimiter) ( // start of capture group 1 \".*?(?&lt;=[^\\])\" // a token bounded by quotes | // OR .*?(?&lt;!\\(?=\|))(?=")? // a token not bounded by quotes, any characters up to the delimiter (unless escaped) | // OR // empty token ) // end of capture group 1 (?=\||$) // look ahead to make sure the token is followed by either a delimiter or the end anchor (last token) when you actually use it it'll have to be escaped as: (?&lt;=^|(?&lt;!\\\\)\\|)(\\\".*?(?&lt;=[^\\\\])\\\"|.*?(?&lt;!\\\\(?=\\|))(?=\")?|)(?=\\||$) </code></pre> <p>It's complicated, but there's method to this madness: Other regular expressions I googled would fall over if either a column at the start or end of the line was empty, delimited quotes were in odd places, the line or column started or ended with an escaped delimiter, and a bunch of other edge-case scenarios.</p> <p>The fact that you're using a pipe as a delimiter makes this regex even more difficult to read/understand. A tip is where you see a pipe by itself "|", it's a conditional OR in regex, and when it's escaped "\|", it's your delimiter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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