Answers for "checking if one string contains other string"

4

find a string contain in another string

#!/bin/bash

STR='GNU/Linux is an operating system'
SUB='Linux'
if [[ "$STR" == *"$SUB"* ]]; then
  echo "It's there."
fi
Posted by: Guest on June-29-2020
0

check if string is substring of another string

function mutation(arr) {
  let first = arr[0];
  let second = arr[1];
  
  return first.indexOf(second) !== -1;
}

console.log(mutation(["hello", "hel"]));
Posted by: Guest on September-04-2021

Code answers related to "checking if one string contains other string"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language