[R] Extracting File Basename without Extension

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jan 9 23:55:35 CET 2009


On Fri, Jan 9, 2009 at 4:28 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
> Rau, Roland wrote:
>>
>> P.S. Any suggestions how to become more proficient with regular
>> expressions? The O'Reilly book ("Mastering...")? Whenever I tried
>> anything more complicated than basic usage (things like ^ $ * . ) in R,
>> I was way faster to write a new function (like above) instead of finding
>> a regex solution.
>>
>
> the book you mention is good.
> you may also consider http://www.regular-expressions.info/
>
> regexes are usually well explained with lots of examples in perl books.
>
>> By the way: it might be still possible to *write* regular expressions,
>> but what about code re-use? Are there people who can easily *read*
>> complicated regular expressions?
>>
>
>
> in some cases it is possible to write regular expressions in a way that
> facilitates reading them by a human.  in perl, for example, you can use
> so-called readable regexes:
>
> /
>   (.+)    # match and remember at least one arbitrary character
>   [.]     # match a dot
>   [^.]+ # match at least one non-dot character
>   $  # end of string anchor
> /x;
>
> you can also use within regex comments:
>
> /(.+)(?# one or more chars)[.](?# a dot)[^.]+(?# one or more
> non-dots)$(?# end of string)/
>
>
> nothing of the sorts in r, however.

Supports that if you begin the regular expression with (?x) and
use perl = TRUE.  See ?regexp




More information about the R-help mailing list