Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find elements in a character array that contains a string

Tags:

string

r

People also ask

How do you check if a string contains something in an array?

You can use the includes() method in JavaScript to check if an item exists in an array. You can also use it to check if a substring exists within a string. It returns true if the item is found in the array/string and false if the item doesn't exist.

How do you check if a character array contains a character?

contains() method with Examples. The contains() method of Chars Class in Guava library is used to check if a specified value is present in the specified array of char values. The char value to be searched and the char array in which it is to be searched, are both taken as a parameter.


Just use grep:

grep('a', x, value=TRUE)
[1] "aa" "ab" "ac"