Delete char from string

hi,
i have field like that 12-3456
and i wont to delete '-'  to have 123456
what is the best way to do that?
Regards

Hi,
TRANSLATE field USING '- '.
CONDENSE field NO-GAPS.
The TRANSLATE command replaces al '-' with blanks and the CONDENSE, NO-GAPS compresses the string to remove all spaces/blanks.
Cheers,
Aditya

Similar Messages

  • Delete a char from string ?

    Hi,
    I want to delete a char from string. i used the following function.
    String f = formulla.replace('[','');
    The above function doesnt work as it tells me to put a space or some char in 2nd parameter which i dont want. i just want to delete all occurences of some specific char in a string.
    Any suggestion.
    Thanks alot.

    u can do:
    String before;
    char charToReplace;
    StringBuffer tempBuf = new StringBuffer(before);
    for (int i=0; i<tempBuf.length(); i++)
            if (tempBuf.charAt(i)==charToReplace)
                  tempBuf.deleteCharAt(i);
    String after = tempBuf .toString(); HTH
    Yonatan

  • Get chars from string of numerals

    here is what I would like to accomplish:
    Put the last four integers of the systemDate into a variable so I can do some math with them.
    Thanks.

    Excellent.  Thank you for the info.  Very helpful.
    Dewey
    From: jchunick [email protected]
    Sent: Friday, June 03, 2011 4:20 PM
    To: Dewey Parker
    Subject: Re: get chars from string of numerals
    This is a post I made for the wiki which should help: http://director-online.com/dougwiki/index.php?title=Undocumented_Lingo#the_systemDate

  • Bash: delete phrase from string

    Hello Community,
    I have a string of words, "hello my name is batman", and i want to delete my name is from the string. I want to automate this process so that I can use it with other strings (ie. "hello my name is Robin"), but i don't want to be cutting characters because it is a different amount of characters for each one (it's obviously not as simple as "hello my name is..."). Thank you so much.

    The OP wants to delete 'batman', or any name after "is ", so:
      echo "hello my name is batman" | sed 's/\(hello my name is \).*/\1/'
    This will work on any name:
      echo "hello my name is Robin" | sed 's/\(hello my name is \).*/\1/'
    Tony

  • Delete char from op concern

    Hi All,
    We have added a char to our op concern in dev client.
    However no data is associated with this char.
    Is it possible to delete this char. If so how?
    Thanks,
    Reddy

    Hi Reddy,
    Delection of Characterisitc from Op Concern is possible.
    For this, first you need to see all areas where that characteristic has been assigned/used.
    Follow the following steps...
    Go to KECM transaction code, click on "Where used list" on the left side navigation, give the characteristic (which you want to delete) on  the right hand side, then "Execute". The system will display where-all that characterstic has been used (forms, reports etc).
    Delete that characteristic from all those areas of assignment and save.
    Now, come to KEA0, in Data Structure, you will be able to remove that characteristic from your Operating concern.
    Try and reply
    Srikanth Munnaluri

  • Is it possible to save an iPhone back up and access the files later if needed?  I have a string of text sms and iMessages that I would like to save and then delete them from my phone.  Is this possible?

    I have a string of text sms and iMessages that I would like to save and then delete them from my phone, but gain access to them later if I need them.  I prefer to have the string with the date/time stamp vs copying and pasting into a doc or text file.  Is this possible?

    Not unless you buy an app that accesses data from an iTunes backup.  Check in the app store.

  • Help removing char from midpoint of string using deleteCharAt()

    How do you properly remove a char from a String at its midpoint? My attempt is on Line 80 and it does not want to work.
    I am using [http://java.sun.com/j2se/1.3/docs/api/java/lang/StringBuffer.html|http://java.sun.com/j2se/1.3/docs/api/java/lang/StringBuffer.html] as a reference for deleteCharAt()
    Am I on the right track or should I try something else?
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Palindromes extends JFrame implements ActionListener
         JPanel centerPanel = new JPanel();
         JLabel enterDataLabel = new JLabel("  Enter a word or phrase with no punctuation: ");
         JTextField enterDataField = new JTextField(15);
         JLabel displayLabel = new JLabel("");
         JLabel spacer = new JLabel("");
         JButton submitButton = new JButton("Check");
         JButton clearButton = new JButton("Clear");
         public static void main(String[] args) throws IOException
              try
                   UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
              catch(Exception e)
                   JOptionPane.showMessageDialog(null,"The UIManager could not set the Look and Feel for this application.","Error",JOptionPane.INFORMATION_MESSAGE);
              Palindromes f = new Palindromes();
               f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
             f.setSize(300,120);
               f.setTitle("Playing with Palindromes");
               f.setResizable(false);
               f.setVisible(true);
         public Palindromes()
              Container c = getContentPane();
              c.setLayout((new BorderLayout()));
            centerPanel.setLayout(new GridLayout(6,1));
                   centerPanel.add(spacer);
                   centerPanel.add(enterDataLabel);
                   centerPanel.add(enterDataField);
                   centerPanel.add(displayLabel);
                   centerPanel.add(submitButton);
                   centerPanel.add(clearButton);
                   submitButton.addActionListener(this);
                   clearButton.addActionListener(this);
                   c.add(centerPanel, BorderLayout.CENTER);
                   addWindowListener(
                         new WindowAdapter()
                             public void windowClosing(WindowEvent e)
                                    int answer = JOptionPane.showConfirmDialog(null, "Are you sure you want to exit?", "Palindromes", JOptionPane.YES_NO_OPTION);
                                     if (answer == JOptionPane.YES_OPTION)
                                          System.exit(0);
         public void actionPerformed(ActionEvent e)
               String arg = e.getActionCommand();
              if(arg == "Check")
                   String word = enterDataField.getText();
                   int wordSize = word.length();
                  int midpoint = wordSize/2;
                   deleteCharAt(midpoint);
                   StringBuffer lastHalf = new StringBuffer(word.substring(midpoint));
                   StringBuffer firstHalf = new StringBuffer(word.substring(0,midpoint));
                   if (lastHalf == firstHalf)
                        displayLabel.setText(word + " is a palindrome!");
                   else
                        displayLabel.setText(word + " is NOT a palindrome!");                    
              if (arg == "Clear")
                   enterDataField.setText("");
                   displayLabel.setText("");
    }

    Looce wrote:
    80 |               deleteCharAt(midpoint);
    82 |               StringBuffer lastHalf = new StringBuffer(word.substring(midpoint));
    83 |               StringBuffer firstHalf = new StringBuffer(word.substring(0,midpoint));line numbering courtesy of GNOME's text editor(replying to self)
    deleteCharAt is an instance method of StringBuffer, so you need to have one to work with. Suggestion: drop lines 82/83 and use String result = new StringBuffer(word).deleteCharAt(midpoint).toString();

  • I have to generate a 4 char unique string from a long value

    I got a requirment
    I have to generate a 4 char unique string from a long value
    Eeach char can be any of 32 character defined has below.
    private static final char char_map[] = new char[]{'7','2','6','9','5','3','4','8','X','M','G','D','A','E','B','F','C','Q','J','Y','H','U','W','V','S','K','R','L','N','P','Z','T'};
    So for 4 char string the possible combination can be 32 * 32 * 32 * 32 = 1048576
    If any one passes a long value between 0 - 1048576 , it should generate a unique 4 char string.
    Any one with idea will be a great help.

    Well, a long is 64 bits. A char is 16 bits. Once you determine how you want to map the long's bits to your char bits, go google for "java bitwise operators".

  • How to skip 3 chars when use "scanf from string" by the parameter "format string" ?

    hi, I want to read a num 123 from the string like that "sfg123" "fgd123" "ghj123"
    I know that I can use "%3s" to skip 3 chars, but it will add an output to "scanf from string"
    So, how to use parameter "format string" not only to skip 3 chars, but also add no output to the "scanf from string"
    Solved!
    Go to Solution.
    Attachments:
    1.JPG ‏15 KB

    Hi Chenyin,
    Try this VI....
    I think... This is what you are expecting....
    <<Kudos are welcome>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • How to get a char from a String Class?

    How to get a char from a String Class?

    Use charAt(int index), like this for example:
    String s = "Java";
    char c = s.charAt(2);
    System.out.println(c);

  • Delete charaters from a string

    hi friends
    i want to delete all the charaters after ".". for example 200.00 to 200
    Regards

    I'd write this differenly now, but here's my old String utilities class...
    package krc.utilz;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.util.List;
    import java.util.ArrayList;
    * Some handy String manipulation methods
    public abstract class Stringz {
       * returns the given string with the characters in the opposite order.
       * @param string String - the string to reverse.
       * @return String backwards.
      public static String reverse(String string) {
        return new StringBuffer(string).reverse().toString();
       * Returns the given string with the first letter in uppercase. Note that
       * the case of the rest of the characters in the string remains unchanged.
      public static String capitalise(String string) {
        return string.substring(0,1).toUpperCase() + string.substring(1);
       * returns a string of howMany spaces, or optionally a string of howMany ch's
      public static String spaces(int howMany) {
        return spaces(howMany, ' ');
      public static String spaces(int howMany, char ch) {
        if (howMany <= 0) return "";
        char[] chars = new char[howMany];
        for(int i=0; i<howMany; i++) chars=ch;
    return new String(chars);
    * right pad string to width
    * @param string String = the string to pad
    * @param width int = the desired width of the string
    * @return String the right-padded string.
    * @deprecated - just use String.format("%-${width}s", string);
    @Deprecated
    public static String padRight(String string, int width) {
    return String.format("%-"+width+"s", string);
    //return string + spaces(width - string.length());
    * left pad string to width
    * @param string String = the string to pad
    * @param width int = the desired width of the string
    * @return String the left-padded string.
    * @deprecated - just use String.format("%${width}s", string);
    @Deprecated
    public static String padLeft(String string, int width) {
    return String.format("%"+width+"s", string);
    //return spaces(width - string.length()) + string;
    * find the first token in a string starting at start. think strpbrk.
    * For example<code>
    * String xml = "<tag attr="value">content</tag>"
    * int x = firstOf(xml, " >");
    * System.out.println(x>0 ? s.substring(1,x) : "UNKNOWN");
    * </code>
    * Produces:<code>tag</code>
    * @param string String = the string to search
    * @param tokens String = a logical array of chars to seek
    * @param OPTIONAL start int = start searching string here
    * @return the index of the fist occurence in string of the first found
    * char in tokens, else (no tokens where found) returns -1;
    public static int firstOf(String string, String tokens) {
    for(int i=0; i<string.length(); i++) {
    char ch = string.charAt(i);
    for(char token : tokens.toCharArray()) {
    if (ch==token) return i;
    return -1;
    public static int firstOf(String string, String tokens, int startIndex) {
    return Stringz.firstOf(string.substring(startIndex), tokens);
    * Returns the prefix of the given string which proceeds the first occurrence
    * of any of the given tokens... optionally starting at the given startIndex.
    * <p>
    * For example<code>
    * System.out.println(substring("<tag attr=\"value\">content</tag>", "< >"));
    * </code>produces<code>tag</code>.
    * @param string String - the string to search
    * @param tokens String - a list of chars which serve as end markers
    * @param start int - OPTIONAL start searching string here, 0 based.
    * @return String string[start..token-1], else the empty string
    public static String prefixOf(String string, String tokens) {
    int end = Stringz.firstOf(string, tokens);
    return end==-1 ? "" : string.substring(0,end);
    public static String prefixOf(String string, String tokens, int startIndex) {
    return(Stringz.prefixOf(string.substring(startIndex), tokens));
    * Splits the given string into chunks of the given size.
    * @param string String - The string to split up.
    * @param size it - The size of each chunk.
    public static String[] chunk(String string, int size) {
    Pattern pattern = Pattern.compile(".{1," + size + "}");
    Matcher matcher = pattern.matcher(string);
    List<String> result = new ArrayList<String>();
    while ( matcher.find() ) {
    result.add(matcher.group());
    return result.toArray(new String[result.size()]);
    Edited by: corlettk on 3/08/2008 10:54 - gave up chasing dependencies - just post the whole class.

  • Delete last char from a console window.

    Hey all, could be a silly question.......
    Is it possible to delete a char from a console window?
    e.g.
                     System.out.print("-");
                   System.out.print("|");
                   System.out.print("/");
                   System.out.print("\\");I'm trying to give the illusion of the line spinning, but cant delete the last printed character. I've tried adding "\b" but with no joy.
    And help would be nice, as it's the little things that always take the longest!
    T.

    @Op. You can use JCurses if you accept that your code might not execute on all platforms.
    http://sourceforge.net/projects/javacurses/

  • Deprecated conversion from string constant to 'char*'

    Hi all
    I am working with strings and i cant figure out why the following
    warning appears at time of build.
    warning: deprecated conversion from string constant to 'char*'
    It appears for the line
    char *myName = "Apple.txt";
    Is there anyone who can help me?
    Help is welcome.
    Thanks in advance.

    Any reason why you aren't using NSString in place of char?
    char *myName = "Apple.txt";
    NSString *myName = @"Apple.txt";

  • How to delete images from folder which are not in the database

    I am created windows form
    i wont to delete images from the folder where i have stored images but i only want to delete those images which are not in the data base.
    i don't know how it is possible . i have written some code
    private void button1_Click(object sender, EventArgs e)
    string connectionString = "Data Source";
    conn = new SqlConnection(connectionString);
    DataTable dt = new DataTable();
    cmd.Connection = conn;
    cmd.CommandText = "select * from tbl_pro";
    conn.Open();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(dt);
    int count = Convert.ToInt32( dt.Rows.Count);
    string[] image1 = new string[count];
    for (int i = 0; i < count; i++)
    image1[i] = dt.Rows[i]["Image1"].ToString();
    string[] image2 = new string[count];
    for (int i = 0; i < count; i++)
    image2[i] = dt.Rows[i]["Image2"].ToString();
    var arr = image1.Union(image2).ToArray();
    string[] arrays;
    String dirPath = "G:\\Proj\\";
    arrays = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();
    int b= arrays.Count();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    var del = arrays[j].ToString();
    else
    foreach (var value in del) // ERROR DEL IS NOT IN THE CURRENT CONTEXT
    string filePath = "G:\\Projects\\Images\\"+value;
    File.Delete(filePath);
    here error coming "DEL IS NOT IN THE CURRENT CONTEXT"
    I have to change anything .Will It work alright?
    pls help me
    Sms

    Hi Fresherss,
    Your del is Local Variable, it can't be accessed out of the if statement. you need to declare it as global variable like below. And if you want to collect the string, you could use the List to collect, not a string.  the string will be split to chars
    one by one.
    List<string> del=new List<string>();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    del.Add(arrays[j].ToString());
    else
    foreach (var value in del)
    string filePath = "G:\\Projects\\Images\\" + value;
    File.Delete(filePath);
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Hi,delete file from folder?

    hi,i am deleting file from folder as follwos
    <%@ page import="java.io.File" %>
    <%
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\xyz.txt");
    myFile.delete();
    %>
    i am sucessfuly deleted file from above path.
    if i use follwing code i unable to delete my file, can one help,
    how to do it,
    <%@ page import="java.io.File" %>
    <%
    String fname="xyz.txt";
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\'"+fname+"'");
    myFile.delete();
    %>
    thanks
    pullareddy

    i think if above doesn't work try this it should work
    change this line
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\'"+fname+"'");
    to this
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\"+fname);

Maybe you are looking for