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



Home Answers Viewqa Java-Beginners Stripping of unwanted characters from string

Have Programming Question? Ask it here!
 
 
 


Anly Vathana
Stripping of unwanted characters from string
1 Answer(s)      3 years and 2 months ago
Posted in : Java Beginners


how to strip off unwanted characters from a string


Advertisement
View Answers

February 3, 2011 at 10:37 AM


Hi Friend,

Try this:

public class StripCharacters {
   public String strip(String s) {  
    String st =" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    String result = "";
    for ( int i = 0; i < s.length(); i++ ) {
        if ( st.indexOf(s.charAt(i)) >= 0 )
           result += s.charAt(i);
        }
    return result;
    }
  public static void main(String args[]) {
     StripCharacters t = new StripCharacters();
     System.out.println(t.strip("Hello **%$#)(World>"));
     }
}

Thanks



Related Tutorials/Questions & Answers:
Stripping of unwanted characters from string
Stripping of unwanted characters from string  how to strip off unwanted characters from a string   Hi Friend, Try this: public class StripCharacters { public String strip(String s) { String st
Unwanted characters instead of arabic characters
Unwanted characters instead of arabic characters  I am using...;%}} %> When I run this JSP, I am getting unwanted characters instead of Arabic... and using it to display. the problem is: I need to display some arabic characters here
Advertisements
Removing characters from a string
Removing characters from a string  Removing characters from a string...(String []args){ String str="Hello 123.you are At 3456"; String...() method removes all blank spaces in the string
Remove duplicate characters from the string
Remove duplicate characters from the string In this tutorial, you will learn how to remove duplicate characters from the string. Java has provide several.... Here we are going to remove duplicate characters from the string
How to Remove Repeated Characters from the String?
How to Remove Repeated Characters from the String?  Hi, I trying to develop an application which will remove the repeated characters from... the example of how to remove repeated characters from the string. Please visit
Remove Repeated Characters from the String
Remove Repeated Characters from the String In this we are going to remove repeated characters from the string. For this, we have allowed the user to enter the string. The class BufferedReader reads the string from the console. Then we
Iterating the Characters of a String
Iterating the Characters of a String This section illustrates you how to iterate the characters of a string. For bi-directional iteration over the text , you... this interface for the string. In CharacterIterator, characters are indexed
how to get string between two characters
how to get string between two characters  hgow to get string from between two characters. ex:hareesh.arava@gmail.com from the above word i want a string between characters . and @ send the required method and give better example
How To Protect Special Characters in Query String?
How To Protect Special Characters in Query String?  How To Protect Special Characters in Query String
Count Characters from the input string Java
Count Characters from the input string of Java In this section, you will learn how to count the occurrence of each character in the string. For this, we have... the string from the console. Firstly we have removed all the spaces between the string
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 is to String.substring(strtindex, endindex-1) For first six characters is: String
Removing Line Termination Characters from a String
Removing Line Termination Characters from a String... of with program code which reads the string or text of a text file which... the string as output in the console, you will understand where the new line
Java count characters from file
Java count characters from file In this section, you will learn how to count characters from the file. Description of code: Firstly, we have used FileReader... into string. Then we have removed all the spaces between the string using replaceAll
Count characters from text file in Java
Count characters from text file in Java  At the "Count chracters fro... is a java code that count the occurrence of each character from text file. import... void main(String[] args) throws Exception{ FileInputStream fstream = new
Escaping Special Characters in a Pattern
characters from the given string or text. Here, you can learn the way of detecting all special characters present in the given string. Program Result... special characters in the given string or text. This program finds special
String substring method example
.style1 { font-size: medium; } String substring() method example:- In the Action Script3, substring are sequential characters that are found from a string. String class provide methods for finding substring from string. Method
Removing character from a string in sql.
Removing character from a string in sql.  Removing special characters from a string in sql
Java String Case Converter
Java String Case Converter Here we are going to convert lowercase characters to upper case and upper case characters to lower case simultaneously from the given input string. Description of code: Through the following code, we have
Extarct string from PDF
Extarct string from PDF  how can i search a particular character from pdf? also extarct string from a pdf document
Java dom from string
Java dom from string  Hi, How to create dom tree from string data? I am trying to search the example for java dom from string. Thanks   ... UpdateData { public static void main(String[] args) { String url="http
remove a substring from a string
remove a substring from a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also w1.w3 is a subset
While loop break causing unwanted output
While loop break causing unwanted output  Below I will paste my code. My problem is that when I run this I get to input a int and if correct it will output that I was correct but after that it will output something that I'm
remove comma from string php
remove comma from string php  How to remove the last comma from the string in PHP
Removing character from a string in sql.
Removing character from a string in sql.  How to remove or replace character from a string
Removing HTML from a Java String
Removing HTML from a Java String  Removing HTML from a Java String
remove comma from string php
remove comma from string php  How to remove the last comma from the string in PHP?   remove last comma from string names = names.replaceAll(",$", ""); //Or a simple substring: if (names.endsWith(",")) { names
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am trying to get a string from a JTextField so that I can compare it with another String using either compare or equals or compareTo methods of the String class
Java Remove a character from string
Java Remove a character from string In this tutorial, you will learn how to remove a character from the string. There are several methods for examining the content of string, finding characters or substrings within a string, changing
Reading string from file timed
Reading string from file timed  So I want to make a file reader/ buffered reader that reads a new line of the textfile, lets say every 30 second. Like it reads the first line, waiting 30 seconds, read the next line and so one
Regex Literal Characters
to represent characters in a string. Using backslash for specific characters. Unicode... Java: Regex Literal Characters [SERIOUSLY UNDER CONSTRUCTION] Most characters can simply be written directly in a regular expression because they're easy
Java characters
Java characters  How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters
Count Palindromes from the string
Count Palindromes from the string In this section, we are going to find out the number of palindromes from the string. For this, we have allowed the user to input a sentence or string. This string is then break down into tokens using
Protect Special Characters.
Protect Special Characters.  How To Protect Special Characters in Query String
PHP get character from String
PHP Get Character From String To get sub string from a String we can use substr() method. Structure of this method is : string substr (string $var... string of variable $var, the initial index position is denoted by $initial
remove special characters iphone
remove special characters iphone  remove special characters iphone   Remove special characters iphone from Password NSString *outputString = [passwordString stringByReplacingOccurrencesOfString:@"%" withString
create a string from an array using JavaScript
create a string from an array using JavaScript  How to use "join()" to create a string from an array using JavaScript
String Functions In Java
the String from the given array of characters. Syntax : public static String..., int count) : This method is used to get the String from the given array of characters started from the specified index and the number of characters
Count characters from text file in Java
Count characters from text file Using Java Here we are going to count the occurrence of each character from the text file. For this, we have used... all the spaces between the string using replaceAll() method and then convert
String Length
java.lang.String. A string is a sequence of simple characters. We can do many things with the string object like we can find out its length, we can compare...String Length      
Java String
Java String       In this section, you will learn about the java string. Java String is a set of characters such as the string "Hello". It is a combination of H, e, l, l, o
count characters
string entered.. example: please enter your string: selangor melaka kedah... main(String[] args) { int count=0; Scanner input=new Scanner(System.in); System.out.print("Enter string: "); String str
unicode characters
unicode characters  class Unicode { public static void main(String args[]) { char ch='\000a'; System.out.println("ch is:"+ch); } } on compilation this gives following errore:: CharLiteral6.java:5: error: illegal line end
unicode characters
unicode characters  class Unicode { public static void main(String args[]) { char ch='\000a'; System.out.println("ch is:"+ch); } } on compilation this gives following errore:: CharLiteral6.java:5: error: illegal line end
unicode characters
unicode characters  class Unicode { public static void main(String args[]) { char ch='\000a'; System.out.println("ch is:"+ch); } } on compilation this gives following errore:: CharLiteral6.java:5: error: illegal line end
Java get Int from String
Java get Int from String     ... from String. For this, we have defined a string. The method  Integer.parseInt(st) converts the string into the integer. Here is the code
How to evaluate the mathematical expression from the string in J2ME.
How to evaluate the mathematical expression from the string in J2ME.  How to evaluate the mathematical expression from the string in J2ME. For example a string containing "24".From the string i want evaluate the mathematical
How to evaluate the mathematical expression from the string in J2ME.
How to evaluate the mathematical expression from the string in J2ME.  How to evaluate the mathematical expression from the string in J2ME. For example a string containing "24".From the string i want evaluate the mathematical
Extracting position of a particular string from a PDF
Extracting position of a particular string from a PDF  I have a pdf form. I want to knw the exact position(location) of a particular string of that form. Using iText I have extracted all the string from the PDF form, but nt able
Get Character from String
Get Character from String       In this example we will see that how to convert string to array... toCharArray() to convert string to character array. 3. Retrieve character from
how to write to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
 

 

 

DMCA.com