Learn R Programming

cwhmisc (version 2.1)

strmatch: A "shortest unique identifier" match.

Description

If an input string matches no output string, return NA.

If it is an ambiguous match, return 0.

Otherwise return the index of the match.

Exception: if the target string contains "log" and "logistic", and the user type "lo" it is ambiguous, but if he types "log" consider it a perfect match.

Usage

strmatch(inputs, target)

Arguments

inputs
The string to be found as a match.
target
The string which should contain the match.

Value

  • The matched string, if it exists. NA, if input matches no output string. 0 , if ambiguous matches are found.

Examples

Run this code
# strmatch(c("he","we"), c("She will","in awe","xxxx"))

Run the code above in your browser using DataLab