STRING STARTS AND ENDS WITH CERTAIN CHARACTERS

 

************************************************************************ 

W.A.P TO CHECK WEATHER A STRING STARTS AND ENDS WITH CERTAIN CHARACTERS

************************************************************************ 

JAVA Program







   



  
Online compiler

Output:


************************************************************************ 

C Program



Online Compiler 

 

************************************************************************ 

C++ Program

Online Compiler

************************************************************************ 

C# Program


 
 
Output:

************************************************************************ 

PHP Program


Online Compiler

Php is a server side scripting language.

************************************************************************ 

JAVASCRIPT Program

 <script type="text/javascript">
var string = prompt("Please enter a string: ");
var substring = "the";
var testStart= string.startsWith('W');
var testEnd = string.endsWith('e');
console.log(`Starts: ${testStart}`);
console.log(`Ends: ${testEnd}`);
if (testStart && testEnd)
{
  console.log(`${string} starts with W and ends with e`);
}
else if(testStart && !testEnd)
{
  console.log(`${string} starts with W but does not ends with e`);
}
else if(!testStart && testEnd)
{
  console.log(`${string} does not starts with W but ends with e`);
}
else if(!testStart && !testEnd)
{
  console.log(`${string} does not starts with W and does not ends with e`);
}



</script>

Online Compiler

************************************************************************ 

PYTHON Program

 

Online Compiler: 

************************************************************************  





Comments

Popular posts from this blog

SAME NAME IN CLASS METHOD AND CONSTRUCTOR

PALINDROME NUMBER

FIBONACCI SERIES