Learn R Programming

Ecfun (version 0.2-2)

camelParse: Split a character string where a capital letter follows a lowercase letter

Description

Split a character string where a capital letter follows a lowercase letter.

Usage

camelParse(x, except=c('De', 'Mc', 'Mac'))

Arguments

x

a character vector

except

character vector giving exceptions: If any of these are found, ignore and look for the next one

Value

list of character vectors

Details

Find all places where a lowercase letter is followed by a capital.

Split on those points

See Also

strsplit

Examples

Run this code
# NOT RUN {
tst <- c('Smith, JohnJohn Smith',
         'EducationNational DefenseOther Committee',
         'McCain, JohnJohn McCain')
tst. <- camelParse(tst)

# }
# NOT RUN {
all.equal(tst., list(c('Smith, John', 'John Smith'),
    c('Education', 'National Defense', 'Other Committee'),
    c('McCain, John', 'John McCain') ) )
# }

Run the code above in your browser using DataLab