Sunday, 19 July 2015

string program


 jsp string()
 

 <html>
<body>
<script type="text/javascript">
var str1=new String("meena");
var str2=new String("kumary");
document.writeln("str1.charAt(0)is:" + str1.charAt(0) );
document.writeln("<br />str1.charAt(1) is:" + str1.charAt(1));
document.writeln("<br />str1.charAt(2) is:" + str1.charAt(2));
document.writeln("<br />str1.charAt(3) is:" + str1.charAt(3));
document.writeln("<br />str1.charAt(4) is:" + str1.charAt(4));

var str3=str1.concat(str2);
document.writeln("<br />Concatenated String:" + str3);

var  str4=new String("this is string one ");
var index=str4.lastIndexOf("one");
document.writeln("<br />lastIndxOf found String:" + index);

var str5="hai meena,hello world.";
document.writeln("(1,2):" +  str5.substring(1,2) );
document.writeln("(0,2):" +  str5.substring(0,2) );

document.write(str5.toLowerCase());


document.write(str5.toUpperCase());

var re=/apples/gi;
var str="apples are round,and apples are juicy.";
if(str.search(re)==-1)
{
document.write("dose not cntain Apples");
}
else
{
document.write("Contains Apples");
}
</script>
</body>
</html>

1 comment: