Seek a Match for the Pattern in the String in R Programming – pmatch() Function Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report pmatch() function in R Language is used to seek match for the pattern passed as argument. It returns the strings that begin with the pattern being searched. Syntax: pmatch(pat, string, nomatch) Parameters: pat: pattern vector to be searched string: vector to be matched nomatch: return when no match is found Example 1: # R Program to match pattern in a string # Creating string vector x <- c("Geeks", "Books", "geek") x # Matching pattern pmatch("gee", x) pmatch("Boo", x) Output: [1] "Geeks" "Books" "geek" [1] 3 [1] 2 Example 2: # R Program to match pattern in a string # Creating string vector x <- c("Geeks", "Books", "geek") x # Matching pattern pmatch(c("Gee", "Boo", "re"), x, nomatch = -1) Output: [1] "Geeks" "Books" "geek" [1] 1 2 -1 Last Updated : 16 Jun, 2020 Like Article Save Article Previous Convert String to Double Quote Text in R Programming - dQuote() Function Next Return a Matrix with Lower Triangle as TRUE values in R Programming - lower.tri() Function Share your thoughts in the comments Add Your Comment Please Login to comment...