text_grep {stringr} R Documentation

apply for batch text grep/trimming/strip

Description

Usage

text_grep(grep.regexp,
    x = NULL);

Arguments

grep.regexp

a regular expression value for produce new text value. [as string]

x

should be a character vector for apply such operation. omit this parameter value will create a lambda function for grep text.

env

[as Environment]

Details

the text grep regexp pattern token should be wrapped inside a bracket: $(regexp_token), any text outside this bracket will be treated as an regular string. example as the token parser string: $(\d+)_$(\[\d*M.*\]\d*[+-]) will be split into 3 tokens: $(\d+) for matches integer string token, _ will always produce a regular string token _, $(\[\d*M.*\]\d*[+-]) for matches another string token that wrapped with bracket [] and ends with signed integer number as suffix.

Authors

SMRUCC genomics Institute

Value

this function returns data object in these one of the listed data types: string, TextGrepLambda.

clr value class

Examples

 let names = ["258_Herniarin_[M+H2O+H]+" "993_Geranyl acetate_[M+H2O+H]+" "3229_Glycerol_[M+NH4]+" "398587_Cytidine_[M+H]+" "398007_Adenosine_[M+H]+"];
 let grep = "$(\d+)_$(\[\d*M.*\]\d*[+-])";
 
 print(text_grep(grep, names));
 # [1] "258_[M+H2O+H]+" "993_[M+H2O+H]+" "3229_[M+NH4]+" "398587_[M+H]+" "398007_[M+H]+"

[Package stringr version 2.33.856.6961 Index]