John Hendy <jw.he...@gmail.com> writes: > On Tue, Aug 5, 2014 at 2:02 PM, Eric Schulte <schulte.e...@gmail.com> wrote: >> Charles Berry <ccbe...@ucsd.edu> writes: >> >>> Eric Schulte <schulte.eric <at> gmail.com> writes: > > [snip] > >>> Eric, >>> >>> As noted by Andreas and John this is a problem for session output. >>> >>> org-babel-R-evaluate-session uses >>> >>> (string-match "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) >>> >>> to find the start of R output in the session. >>> >>> This does not match the ` 0', but matches the ` .6' >>> in the output you show above, so if that had been in a session, all the >>> output up to and including the '.' before the '6' would be clipped >>> by the following >>> >>> (substring line (match-end 1)) >>> >>> >>> as Andreas output showed. >>> >>> Deleting the "\\." fixes Andreas case, but what are the circumstances >>> requiring the "\\." ? >>> >> >> I don't know. > > I'm not sure either, but was curious if someone could translate the > regex into "plain language." Maybe I could observe some typical > outputs and chime in since I use R regularly? From noob-level regex > stuff, it's looking for a new line followed by some number of spaces, > a ">" and at least one period and numbers? >
It says[fn:1] ^ anchor the match at the beginning of the line \\([ ]*[>+\\.][ ]?\\)+ match any number of spaces followed by one of the three characters >, + or . (a literal period) followed by 0 or 1 space. If there is a match, remember what is matched as group 1 (that's what the escaped parentheses \\(...\\) do). Match one or more of these (that's what the + at the end does). \\([[0-9]+\\|[ ]\\) match either an emtpy space or a sequence of one or more of the characters [ or 0-9 i.e. an opening square bracket or a digit. remember what is matched as group 2. The latter will match [0[1[2[3 e.g. which does not sound right. The best way to find out what a regexp will match is to start with a buffer containing example strings that you are trying to match and example string that you are trying *not* to match, then invoke M-x regexp-builder and paste the regexp inside the empty set of quotes, then check the highligted matches to see if they agree with your expectations. Footnotes: [fn:1] Crossing fingers and toes, hoping I've got it right... -- Nick