Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions find the first character is vowel or not
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


arpita rajan patel
find the first character is vowel or not
2 Answer(s)      3 years and 6 months ago
Posted in : JavaScript Questions


hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check wehter it contains a space any where 4)replace all the "a" with "e" 5) extract the last three characters and check if it is "com" or not


Advertisement
View Answers

March 12, 2011 at 12:14 PM


<html>
<script>
function check(){
var str=document.getElementById("st").value;
var ch=str.charAt(0);
if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u'){
alert("First character of string is vowel");
}
else{
alert("First character of string is not vowel");
}
var ch1=str.charAt(str.length-1);
if(ch1==ch){
alert("Last character is same as the first character");
}
else{
alert("Last character is not same as the first character");
}
var space = new RegExp("/^\s+$/");
if (space.test(str)) {
alert("String contains white space character");
}
else{
alert("String does not contain white space character");
}
var newst=str.replace("a","e");
alert("New String: "+newst);
var s=str.substr(-3);
if(s=="com"){
alert("It is com");
}
else{
alert("No");
}
}
</script>
Enter string <input type="text" id="st"><input type="button" value="check" onclick="check();">
</html>


March 12, 2011 at 2:20 PM


<p><html>
<head></p>

<script type="text/javascript">
function strfun()
{
    my_str="aeiouAEIOU";
    my_char=document.forms(0).t1.value.charAt(0);
if(my_str.indexOf(my_char)>=0)
{
alert("the 1st character vowel");
}
else
{
alert("The 1st character is not a vowel");}


var str1,str2;
str1=document.forms(0).t1.value.charAt(0);
str2=document.forms(0).t1.value.charAt((document.forms(0).t1.value.length)-1);
if(str1==str2)
{
alert("last and first chracter are same");
}

 var a=document.forms(0).t1.value;
    for(i=0;i<a.length;i++)
    {
    if(a.charCodeAt(i)==32)
    {   alert("string contains white space character");

    }
}
document.forms(0).t1.value=document.forms(0).t1.value.replace(/a/gi,'e');
{
    alert("replace a with e");}

 var s=a.substr(a.length-3,a.length);
if(s=="com")
{alert("it is com");
}
else
{alert("it is not com");}

}

</script>

<p></head>
<body></p>

<form name="f1" method="post">
<table>
<tr>
<td>Enter String:</td>
<td><input type="text" name="t1"></td>
</tr>
<tr>
<td><input type="button" value="submit" onclick="strfun()"></td>
<td><input type="reset" value="reset"></td>
</tr>
</table>
</form>

<p></body>
</html></p>


Related Tutorials/Questions & Answers:
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
Find the percentage of words which starts with a vowel in a file
Find the percentage of words which starts with a vowel in a file   Question: Find the percentage of words which starts with a vowel in a file. Ex: Input: Contents of File1- There is an endless loop in the program. Output: Vowel
Advertisements
vowel
vowel  display all the vowel from word/string   import java.util.*; class DisplayVowels { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter
Find out last character of array
Find out last character of array  How we can find out the last character of array in java program
Find Character form String example
in the string. The first character index position is 0.  String provide charAt() method to find out the character in the string with the help of index position, and also find the character code using charCodeAt() method. User can see how
find all unique character in string using java
find all unique character in string using java  example: hello how are you. output should be waryu
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Find Successively Repeated Character using Java
Find Successively Repeated Character using Java In this section, we are going to find the successively repeated character using Regular Expression... Character is m
How to find the first 6 characters of string in regex?
How to find the first 6 characters of string in regex?  How to find the first 6 characters of string in regex. I know the Syntax... need the syntax to find the first 6 characters of string in regex using java
java string vowel program
java string vowel program  java string vowel program   Please visit the following links: Display the word that begins with vowel Java Count Vowels
java vowel program - Java Beginners
java vowel program  Write a program to Print all the words that start with a vowel and end with a consonant. For example : Input :??the purpose... = st.nextToken(); Character ch=Character.valueOf(token.charAt(0)); if ((ch
plz give me program to this: Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
plz give me program to this: Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1
2. Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
2. Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1 Abracadabra, 2 Abracadabra, 3
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
Find number of words begin with the specified character
down the string into tokens and matches the first character of every token...Count number of words begin with the specified character In this section, you... character from the string. To do this, we have allowed the user to input a sentence
Character Class
Character Class  Character defines the forDigit();,digit()methods..how can these b used and wht is radix point signifies here...in the arguments of these two???..pls answer a code on this with radix .. are these methods also
Character class
Character class   Character defines the forDigit();,digit()methods..how can these b used and wht does radix point signify here.i want to knw what basically radix is??here in the arguments of these two???because i tried runnin
underscore as character
underscore as character  how can i consider _ as a character instead of wildcard character? my problem is like this i have 20 records as follows manohar 1234455 manohar 453635 manohar 345454 manohar_1234455 now when i am
Replace Character in String
in a given string. To replace a character with the given character in sting first... find then replace the "oldChar" with newChar (character name to replace... Replace Character in String      
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
First Java Program
Welcome to java tutorial series. In this lesson, you will learn to create your first Java program. In Java, all source code is written in plain text file... Machine. You can write a Hello World program as your first Java program. To write
accept sentence from user and print all word starts with vowel and end with consonent
accept sentence from user and print all word starts with vowel and end with consonent  Write a program to accept a sentence. Print all the words that starts with vowel and end with a consonant. e.g. input by user "the purpose
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
replace character in php
replace character in php  PHP script that replace character
character counter - Java Beginners
character counter  how to show only first three characters...!!"); } else{ System.out.println("First Three Character is:"+c[0]+c[1]+c[2... to show first three characters of entered name. import java.io.*; class
Character Wrapper Class.
Character Wrapper Class.  what are Mirrored Unicode Characters?? and whats the use of "isMirrored(ch);method ??.where ch is any character argument.... There are special characters in UNICODE to achieve the RTL. Such character is the Mirroring
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
How to display string or character
How to display string or character  how to print character or a word without using array concept
password validation with special character
password validation with special character  how to validate password with special character using java script
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
 

 

 

DMCA.com