stringi (version 0.2-5)

stri_count_charclass: Count the Number of Character Class Matches

Description

This function counts the number of characters that fall into a given character class (e.g. letters, digits, or white spaces).

Usage

stri_count_charclass(str, pattern)

Arguments

str
character vector to search in
pattern
character vector specifying character classes to match, see stringi-search-charclass

Value

  • Returns an integer vector.

Details

Vectorized over str and pattern.

See Also

Other search_charclass: stri_detect_charclass; stri_extract_all_charclass, stri_extract_first_charclass, stri_extract_first_charclass, stri_extract_last_charclass, stri_extract_last_charclass; stri_locate_all_charclass, stri_locate_first_charclass, stri_locate_first_charclass, stri_locate_last_charclass, stri_locate_last_charclass; stri_replace_all_charclass, stri_replace_first_charclass, stri_replace_first_charclass, stri_replace_last_charclass, stri_replace_last_charclass; stri_split_charclass; stri_trim, stri_trim, stri_trim_both, stri_trim_left, stri_trim_right; stringi-search-charclass; stringi-search

Other search_count: stri_count_coll; stri_count_fixed; stri_count_regex; stri_count; stringi-search

Examples

Run this code
if (stri_install_check(silent=TRUE))
stri_count_charclass(c("stRRRingi", "STrrrINGI", "123"),
   c("\\p{Ll}", "\\p{Lu}", "\\p{Zs}"))

if (stri_install_check(silent=TRUE))
stri_count_charclass("\t\n", "\\p{WHITE_SPACE}") # white space - binary property

if (stri_install_check(silent=TRUE))
stri_count_charclass("\t\n", "\\p{Z}") # whitespace - general category (note the difference)

Run the code above in your browser using DataLab