[R] using regular expressions to retrieve a digit-digit-dot structure from a string

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jun 8 19:36:59 CEST 2009


Try this.  See ?regex for more.

> x <- 'This happened in the 21. century." (the dot behind 21 is'
> regexpr("(?![0-9]+)[.]", x, perl = TRUE)
[1] 24
attr(,"match.length")
[1] 1


On Mon, Jun 8, 2009 at 10:15 AM, Mark Heckmann<mark.heckmann at gmx.de> wrote:
> Hi,
>
>
>
> i need to recognize itemization structures in strings which follow the
> format: "digit-digit-dot" like e.g.
>
>
>
> 1.
>
> 2.
>
> 19.
>
> 211.
>
>
>
> Given the string " This happened in the 21. century." (the dot behind 21 is
> used in German instead of 21st) I want know where the dots are but I do not
> want the 21.-dot to be returned as well.
>
>
>
> I am not good at regular expressions. How can I retrieve or recognize dots
> excluding the digit-digit-dot structure?
>
>
>
> TIA, Mark
>
>
>
> -------------------------------
>
> Mark Heckmann
>
> + 49 (0) 421 - 1614618
>
> www.markheckmann.de
>
> R-Blog:  <http://ryouready.wordpress.com> http://ryouready.wordpress.com
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>




More information about the R-help mailing list