Strip the first character from a string

i am trying to strip the leftmost character from a string
using the following:
<cfset Charges.DTL_CHG_AMT_EDIT =
#Right(Charges.DTL_CHG_AMT_EDIT,Len(Charges.DTL_CHG_AMT_EDIT)-1)#>
i keep getting the following error:
Parameter 2 of function Right which is now -1 must be a
positive integer

> RemoveChars() much easier than Right()? How so?
Semantically, if the object of the exercise is to *REMOVE
CHARacters from a
string* (which it is, in this case), it is simply better
coding to use
removeChars() rather than right(). That, and it's one less
function call
(the RIGHT() solution also requires a call to LEN() for it to
work).
So removeChars() is "easier" because it reflects the intent
of the exercise
directly, is simpler logic, is easier to read, and - I can't
be arsed
counting keystrokes - is probably less typing.
That'd be how.
Adam

Similar Messages

  • The first character in a string

    I need to return the first character of a string, convert it to an integer, and compare it with another integer to see if they're the same. Sounds simple, even for me, but it won't work!!!
    // First question >
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    Variables.placeholder = (int) userValue1.charAt(0);This is the error I get
    C:\Documents and Settings\imholt\My Documents\OOPAttempt\21_Questions\Engine.java:170: cannot resolve symbol
    symbol : method charAt (int)
    location: class java.lang.Object
              Variables.placeholder = (int) userValue1.charAt(0);
    ^
    1 error
    I have a sneaky suspicion that once I find out what the problem was, I will ask myself why I didn't see it before...

    Try this
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    String str = userValue1.toString();
    Variables.placeholder = (int) str.charAt(0);

  • Get first character from a String

    Hi!
    I've got a problem with the login of my program:
    I want to get the first character out of a String to select two types of users.
    eg.
    login "a20202" --> a --> first kind of user or
    login "b20202" --> b --> second kind of user
    Can you please help me?
    Bye
    Liz

    Am I on way to challenge the Worst Code Awards 2004 ? Let me have a go ... It is a far superior code-generating version :)
    Kept to ascii-range for the benefit of your monitor (and eyes):class NoMyWayIsFarSuperior {
         public static void main(String[] args){
              System.out.println("public static char getFirstChar(String message){");
              for(int k = 0; k < 256; k++){
                   System.out.println("  if(message.charAt(0) == " + k + ") return '" + ( (char) k) + "';");
              System.out.println("  throw new Exception(\"First char not within ascii range ... Please try again.\"); ");
              System.out.println("}");
    } The potential for optimisation is endless! :)

  • Replace the first character in a String with blank

    String a = dgramRsp.getAddress().toString();
    a = a.replace('/','');The problem with the first statement is that it returns an ip address with a '/' in front of it. Like so.../192.168.0.190
    I need to get rid of the '/'. The replace won't work because it wants a character between the ' '. Thanks for your time.

    I had to think about it for a sec but yes you're
    right.
    InetAddress a = dgramRsp.getAddress();
    String b = a.getHostAddress();
    substring(1) would have worked, too, but it would have been redundant (removing a previously added slash).

  • TestStand database logging problem: only the first character is put in the table.

    I am using TestStand 2.0.1 and Microsoft SQL server database. There is a weird problem when I use database logging. At first, all the database logging ran good.
    Then one day after I moved the test equipment to production line, TestStand only logs the first character of each string field in the tables! There is no error message.
    I setup another SQL server running locally on the same machine as the TestStand is and move the database to the local server, database logging has no problem. Schemas in TestStand Dabasebase Options are the same.
    I tried to run TestStand from another computer on the network. There was no problem before, too.  But now, TestStand always shows a Run-time error message like this:
    Details:
    An exception occurred calling 'LogResults' in 'ITSDBLog' of 'DBLog 1.0 Type Library'
    An error occurred executing a statement.
    Schema: New.
    Statement: STEP_RESULT.
    Connection failureMultiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    Source: TSDBLog
    Error Code:
    -2147467259; User-defined error code.
    Location:
    Step 'Log Results to Database' of sequence 'Log To Database' in 'Database.seq'
    I have checked that the connection is good and also the table UUT_RESULT has been logged correctly.
    Anyone can help?
    Thanks.

    Thank you very much, Santiago.
    Yes, I have a customized schema, but it is based on the pre-existing schema. I tried the schema:TS 1.x Access/SQL (NI), which  came with TestStand, the results were the same. 
    I have tried to run different sequences. On one computer, I always get only the first character of each string entry logged in the remote database, however for the local server, everything is fine. On the other computer, there is no local SQL server, I always get similar error message as I mentioned in my post. The sequence step reports error is  "Log Results to Database".
    Any more suggestion?
    Thanks again.
    Best regards,
    Jaso

  • Please Help: Ignore first Character in a String.

    How do you ignore the first Character in a String?
    String a = JTable.getValueAt(row,column).toString();
    //Ignore first Char of a? ('$')
    double b = Double.valueOf(a).doubleValue();Any help would be appreciated!

    Ok,so I do that. Now I have the Char '$'. But I don't want '$', I want everything after it. Must I loop throught the rest of the string or can I just remove the first Char?

  • Only display the first character issue

    Hi,
    I'm using CR 2008 to generate reports.
    I use oracle database.
    I use a stored procedure to get data and everything working fine ,it return correct data.
    I have five details section but i display one details section and i suppress others
    My issue is execute the rpt file to presssig F5 key;   string type record is only able to print the first character on the preview.
    eg: record with value 'ABCDE', after printed on rpt file, only character 'A' was printed on the preview.
    if i verify database, it display correct data but a few times later problem occurs again
    Anyone know how to fix it?

    if you create a blank report as follows , you will take same error
    my reports section;
    section - formula fieds 
    a - - - - a b f g
    b - - - - a b e f g
    c - - - - a b c e f g
    d - - - - c f g
    e - - - - d e f g
    my details sections suppress formula;
    if {CR_TEST.CODE}=1 then false else true
    if {CR_TEST.CODE}=2 then false else true
    if {CR_TEST.CODE}=3then false else true
    if {CR_TEST.CODE}=4 then false else true
    if {CR_TEST.CODE}=5 then false else true
    my procedure is just like this;
    CREATE OR REPLACE PROCEDURE CR_TEST(
       P_MONTH IN VARCHAR2
    , P_YEAR IN VARCHAR2
    , CODE IN NUMBER
    , P_CURSOR OUT GP.REF_CURSOR
    IS
    BEGIN
       IF CODE = 1
       THEN
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , 'X' C
                  , 'X' D
                  , 'X' E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 2
       THEN
          --A, B, E, F, G
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , 'X' C
                  , 'X' D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 3
       THEN
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , C
                  , 'X' D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 4
       THEN
          OPEN P_CURSOR FOR
             SELECT 'X' A
                  , 'X' B
                  , C
                  , 'X' D
                  , 'X' E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 5
       THEN
          OPEN P_CURSOR FOR
             SELECT 'X' A
                  , 'X' B
                  , 'X' C
                  , D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       END IF;
    END;
    Edited by: assaulter on Oct 12, 2011 11:50 AM
    Edited by: assaulter on Oct 19, 2011 1:50 PM

  • Even more about deleting the first word in a string

    hi, i have this code that removes the first word in a string, returns the shorter string, removes the first word from the shorter string aso... what i would like it to do is to stop when it hits a non-character, but i can't get it to do that. does anyone know why \b won't work?
    import java.io.*;
    class Testar {
    public static void main(String[] args) {
          String partDesc = "Hi my name is SandraPandra.";
          while (partDesc.equals("\b") == false) {  //this is where something goes wrong
              System.out.println(partDesc);
              partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
    } thanx in advance!

      while (partDesc.equals("\b") == false) That compares partDesc to a string consisting of one backspace character. I suspect you're trying to use the regex word-boundary anchor, but that's a dead end. If you want to stop beheading the string when the regex stops matching, you can write the code exactly that way: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        while ( partDesc.matches("^(\\w+)\\s+.*") ) {
          partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
          System.out.println(partDesc);
    } If performance is a concern, you can use a pre-compiled Pattern object for greater efficiency. Thanks to Matcher's lookingAt() method, you can use the same regex for the test and the replacement: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        Pattern p = Pattern p = Pattern.compile("^(\\w+)\\s+");
        Matcher m = p.matcher(partDesc);
        while ( m.lookingAt() ) {
          partDesc = m.replaceFirst("");
          System.out.println(partDesc);
          m.reset(partDesc);
    } The ^ anchor isn't really necessary in this version, since lookingAt() implicitly anchors the match to the beginning of the string, but you might as well leave it in.

  • UDF for Find the First letter from Input

    Hi Masters,
    I want find the first letter from input, Can any one help me on this..UDF or any solution.
    Ex: E2HB means - Alpha Letter is the first
    Ex: 1234 means - Number is the first
    Thanks,
    Siva

    Hi Siva,
                I just want to clarify this doubt, you want the first character of the string you pass to the UDF i.e if input="E2HB"  output="E"   and if input="1234"   output="1". If my assumption is correct you can try the UDF "firstChar" I have shown below this gives exactly the output you want
    public class firstLetter {
         public static String firstChar(String s)
              if(s==null)
                   return null;
              if(s.equals(""))
                   return s;
              String t="";
              t+=s.charAt(0);
              return t;
         public static void main(String[] args) {
              String s1="E2HB",s2="1234";
              s1=firstChar(s1);
              System.out.println(s1);
              s2=firstChar(s2);
              System.out.println(s2);
    Regards
    Anupam

  • How can a  variable display the first character that's on the page?

    I'm creating a telephone directory and want each page to display the alphabet of the first listing on the page on the top - only one character.
    Can you tell me how to do this?

    Hmmmmm, seems I was wrong about the GREP styles. I just tried it and they don't get picked up. I consider that a bug, but it's probably "as designed."
    That leaves you having to work with nested styles only, or Find/Change. I think what you'll need to do is redefine the Paragraph style so it has two nested styles that apply the correct style to whatever needs to be styled at the start of the paragraph, one for the first character and the second for the rest of the word(s) if you can figure out a trigger (can InData add an end nested style character or is thew some punctuation you can use?), then find/change to remove the applied character style. For that I'd serach for ^.+ with the find format set to the character style that InData applied and the chane format set to [None], which will only remove it from the beginning of your paragraphs. If this is done correctly there will be no change in appearance since the redefined paragraph style will do the formatting.
    If that won't work, you can use find/change to apply a new style to the first characters. Search for ^. and set the change format to the new character style that you'll use in the variable. It needs to have the same attributes as the style applied by InData or the appearance will change.
    The second method is probably easier since you don't need to redfine the paragraph style, but both methods require you to use find/change to alter the text, which means if more text is added you'll need to re-do the find/change. Not a big deal, but don't forget. I'd be tempted to wait until the last minute and just ignore the headers for the moment, if editing is ongoing. I'd also test this on a copy of the file for safety.

  • Replace a character from a string

    Hi,
    how can I replace a particular character from a string on a particular occurrence? Say for eg, if i wan to replace 'a' of second occurrence from 'abcabcabc', then what should i do? I guess the normal REPLACE function replaces every occurrence in a given string. So is there any other way to solve this?
    Thanks!

    If you are in 9i:
    Then you got to split the string into based on the nth position.
    SQL> select replace('abddefabc','a','x') from dual;
    REPLACE('
    xbddefxbc
    SQL> select instr('abddefabc','a',2) from dual;
    INSTR('ABDDEFABC','A',2)
                           7
    SQL> select substr('abddefabc',1,instr('abddefabc','a',2)-1),substr('abddefabc',instr('abddefabc','a',2)) from dual;
    SUBSTR SUB
    abddef abc
    SQL> select substr('abddefabc',1,instr('abddefabc','a',2)-1),replace(substr('abddefabc',instr('abddefabc','a',2)),'a','X') as replaced from dual;
    SUBSTR REP
    abddef XbcOfcourse, later on you can join the string..
    Jithendra

  • How to delete the first page from a large number of documents

    Hello all,
    My company has migrated from Adobe Acrobat pro 8 to 11. In version 8 we had
    used Document Processing to remove the first page from all pdf's within a
    directory (5000+). This process took about an hour.
    Now my research has led me to use Actions in version 11, however it appears
    that the action require each document to be open and saved (one after another)
    in Acrobat in order for the first page to be removed.  This thrashing has made this process very
    slow to the point where it's useable.
    Is there any way to run actions from the command line
    so time isn't wasted opening up each document in Acrobat? 
    Is there another way to quickly remove the first page
    from a PDF in bulk?
    I'm outside my expertise area here, so if you need any additional
    information let me know.
    Thanks in advance.

    Indeed, batch processing in Acrobat XI is inferior in many ways to what it was previously.
    To answer your questions:
    1. No.
    2. Yes, it can be done using a stand-alone app much more quickly and more efficiently, but it's somewhat more complicated to develop such an app than to set up an Action in Acrobat.

  • Extracting the first page from all pdf's in a folder and save them to a new file

    Hi,
    As Bridge apparantly is unable to create a decent-looking PDF from a bunch of other PDF's, we're looking for alternative solutions. The problem is, that I haven't done much scripting in Acrobat.
    Pseudocode:
    Select Folder where PDF files are stored
    Create list of PDF files
    Get first page from each and add it to temporary new PDF
    Save temporary new PDF in high quality
    Would that be possible in Acrobat? And where would I start? I can't even find a Scripting Guide for Acrobat (like the ones for Illustrator and InDesign).. and there seems to be no sample scripts included either :-(
    Thanks,
    Thomas

    This can be done using a combination of an Action and a script. The script in the Action will collect the paths of the files you want to process and the folder-level script will extract the first page from each file and generate a new PDF from it. You don't need a plugin for this task, so you don't really need the SDK.
    The Acrobat JavaScript Reference can be found here: http://www.adobe.com/devnet/acrobat/javascript.html

  • [CS2/CS3 JS] Finding the first character of each paragraph

    Hi,
    Can anybody help with my script below:
    for (h=0; myParaCount>h; h++){
    myChars = myStory.paragraphs.item(h).contents;
    if (myChars.characters.item(0) == "l" && myChars.characters.item(0).appliedCharacterStyle == CharStyleWin){
    myStory.paragraphs.item(h).appliedParagraphStyle = "L-B";
    This script is supposed to test if the first character is an "l" with my character style "Wingdings" applied to it. I could not test whether the character style is "Wingdings" or not. What could be wrong with my script. Thanks.

    // You need to have a textFrame selected
    var myFrame = app.selection[0];
    var myParaCount = myFrame.paragraphs.length;
    // There must exist a paragraphStyle name L-B
    var myApplyStyle = app.activeDocument.paragraphStyles.item("L-B")
    for (h=0; h < myParaCount; h++){
    var myChar = myFrame.paragraphs.item(h).characters.firstItem();
    // check if first char is "l" and if its applied charstyle name is CharStyleWin
    if (myChar.contents == "l" && myChar.appliedCharacterStyle.name == "CharStyleWin"){
    myFrame.paragraphs.item(h).appliedParagraphStyle = myApplyStyle;
    /* Edited at 11.21 */

  • Delay when typing in Safari, the first character is always missing.

    Recently when I go to type in a address or text in the search window, the first first character is always gone. Resulting in me having to back space to the beginning to re-type the first character.
    My father is a Mac user too and he experiences the same thing.
    Any suggestions?

    Hi,
    The problem you described sounds reminiscent of a problem many MacBook, MacBook Pro and even PowerBook G4 users have been experiencing. If you do a Discussions-wide search for the phrase "first key" in quotation marks, you'll get an idea of how wide-spread the problem is. Apple recently released a firmware update for the MacBook and MacBook Pros, but reports of first-key-unrecognition persists.
    While I hope your problem isn't of this variety, the point I'm trying to illustrate is that if it is, Apple has yet to pin down a proper fix for it. Until they do though, perhaps some workarounds you can try are banging on a modifier key before typing anything, or clicking twice to ensure focus has been given to a window element and not just the window.
    Yang

Maybe you are looking for