The most reliable way to split such lines is with parse(text=x).
Regular expressions don't do well with context-free grammars.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Sep 15, 2016 at 12:08 PM, Adrian Du?a <dusa.adrian at unibuc.ro>
wrote:
> Dear R-helpers,
>
> When parsing a text, I would like to separate commands written on the same
> line, by a semicolon.
> Something like:
>
> x <- "foo <- '3;4'; bar <- \"don't ; use
semicolons\""
>
> Ideally, that would translate to these two commands in a character vector
> of length 2:
> foo <- '3;4'
> bar <- "don't ; use semicolons"
>
> It's probably a regexp magic, but I just can't find it.
>
> Any hint is highly appreciated,
> Adrian
>
> --
> Adrian Dusa
> University of Bucharest
> Romanian Social Data Archive
> Soseaua Panduri nr.90
> 050663 Bucharest sector 5
> Romania
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]