Answers for "how to check a string is present in a string"

2

if word exist in string

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
Posted by: Guest on April-28-2020
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

Code answers related to "how to check a string is present in a string"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language