Jeffrey Kramer
Jeffrey Kramer

Reputation: 1345

String Manipulation with Regular Expressions

I'm struggling with another regex expression. I have:

test <- "some.a, stuff.b, is.c, here.d, e, f, goaway.g"
"some.a, stuff.b, is.c, here.d, e, f, goaway.g"

I want:

gsub("??", "", test)
"a, b, c, d, e, f, g"

I can't figure out what to put for my pattern. I tried something like "*\\.?" and it didn't work. I'm no familiar enough with regex to know what I'm doing yet.

Upvotes: 4

Views: 115

Answers (1)

arshajii
arshajii

Reputation: 129497

You can try

[a-z]+\.

As in, gsub("[a-z]+\\.", "", test).

Upvotes: 3

Related Questions