Giter Site home page Giter Site logo

regexcite's Introduction

NOTE: This is an example package mostly copied from the online edition of R Packages (2e). All credits go to the original authors.

Regexcite

The goal of Regexcite is to make regular expressions more exciting! It provides convenience functions to make some common tasks with string manipulation and regular expressions a bit easier.

Installation

You can install the development version of Regexcite from GitHub with:

# install.packages("devtools")
devtools::install_github("yzchang/Regexcite")

Usage

A fairly common task when dealing with strings is the need to split a single string into a plain list of many parts.

This package provides two functions Regexcite::str_split_one() and Regexcite::str_split_multi() that split a single character vector by a single character (i.e. Regexcite::str_split_one()) or one or more character vectors by one or more characters (i.e. Regexcite::str_split_multi()) into a single list of character vector(s).

Example

Use Regexcite::str_split_one() when the input is know to be a single string and the pattern is a single character:

library(Regexcite)
s <- "echo:foxtrot:golf:hotel"
str_split_one(s, ':')
#> [1] "echo"    "foxtrot" "golf"    "hotel"

Use Regexcite::str_split_multi() when the input contains multiple strings or the pattern contains multiple characters:

library(Regexcite)
fruits <- c(
  "apples and oranges and pears and bananas",
  "pineapples and mangos and guavas"
)
str_split_multi(fruits, " and ")
#> [[1]]
#> [1] "apples"     "pineapples" "oranges"    "mangos"     "pears"     
#> [6] "guavas"     "bananas"

regexcite's People

Contributors

yzchang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.