[R] Extracting File Basename without Extension

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Jan 9 22:28:15 CET 2009


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.

vQ




More information about the R-help mailing list