There are many resources for learning regular expressions (e.g. http://gnosis.cx/publish/programming/regular_expressions.html). Once you understand the basics you will probably be able to refer to the ?regex help page for specific tools. After you have waded through a tutorial, the following explanation should make more sense.
The braces are extended regex syntax for a repetition of a pattern by some minimum to some maximum number of times. The pattern immediately precedes the repetition specification. In the first case of {0,1} the pattern being repeated is the comma, and in the second case it is any of the characters in the square brackets (a period in this case). The period is a special "match any character" pattern when not part of a set of characters. A common shorthand for zero or one of something is a + symbol. Also, please learn to provide quoting context for the majority of us who do not use Nabble. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. mdvaan <mathijsdev...@gmail.com> wrote: >Thanks! That works like a charm, but I am not sure if I fully >understand the >syntax. I looked at the gsub page but still couldn't figure it out. >What >does the pattern part (",{0,1} Inc[.]{0,1}") do? What do the 0 and 1 >within >the curly brackets refer to? Also, what if, for example, I would want >to >remove the word "Energy"? > >Thank you very much in advance. > >Math > >-- >View this message in context: >http://r.789695.n4.nabble.com/gsub-strsplit-with-multiple-patterns-splits-tp4631873p4631897.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help@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. ______________________________________________ R-help@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.