Replacing chars in a string by index and not sequence??

Hi,
I wish to replace the first character of a string, the only functions I see are replace and translate but they only replace based on char value, I have a work around do but concat strings and chars but I was wondering if there is a more graceful approach to doing this,
Cheers.

concat strings and chars but I was wondering if there is a more graceful approach to doing thissubstr & concatenation are graceful enough.

Similar Messages

  • Replacing ' char in a string

    How can I add a \(backslash) before before a '(apostrophe) in a String ?
    I've been tryin' myString.replaceAll("'","\'") and myStringBuffer.deleteCharAt & insert but with no success

    sorry... i don't read the API before answering u ;) replaceAll related to regex n it's new for me... it's alredy 11:15 PM, i'm going to sleep (i don't want to learn about regex for now)...
    here is other solution:
    public class ItsWork {
         public static String insertBefore(String original, String add, String before) {
              StringBuffer sb = new StringBuffer();
              int i = 0;
              do {
                   i = original.indexOf(before);
                   if (i != -1) {
                        sb.append(original.substring(0, i));
                        sb.append(add);
                        sb.append(before);
                        original = original.substring(i + 1, original.length());
                   } else break;
              } while (true);
              sb.append(original);
              return sb.toString();
         public static void main(String[] args) {
              String myString = "do this realy don't work?";
              System.out.println(myString);
              myString = insertBefore(myString, "\\", "\'");
              System.out.println(myString);
    }

  • Searching for End of line char in a string...and EOF in string.

    Suppose I open up a file and read it right into a StringBuffer. Once I have that, how can i searching using StringBuffer.indexOf(whathereforEOL) for a end of line, i suspect its perhaps some sort of escape character but I am not sure what it is in java or if java even uses escape characters.
    I really need
    .indexOf(EOL); somehow, and perhaps .indexOf(EOF); //if end of file character is retrieved using a StringBuffer that was completed using a BufferedReader based on a input stream reader.
    Thanks for any info here,
    Shane

    End-of-line is denoted in a platform-specific way.
    Some variations depending on the platform:
    "\r"
    "\n"
    "\r\n"
    A sidenote. I remember some platforms maintaining the notion of "sequential" (and h�las, of "index-sequential") files. Unix and Windows store the files as byte streams without OS-imposed internal structure, that is the point of view of C as well.
    But if you use BufferedReader.readLine() you get the lines one after the other.
    EOF is handled by the OS. You will not read an "EOF" marker.
    -1 rather denotes in the API that end-of-file is reached.
    There is no way to actually read -1 as a byte or a character from a file or other data source.

  • How to replace missing fonts with a specific font (and not a suggested font)

    Hello all!
    Looking to replace missing fonts within my document - but the drop-down selection only gives a couple of suggestions, none of which are the font I want to use.
    How can I replace the fonts with a font of my choosing?
    I've attached an image to give more clarity - notice how the drop-down only gives the option to select between 3 fonts without an option to select your own font - many thanks!

    Same problem! The only solution I found is to prepare a textbox in a new file with all the font you need. Copy and past in the file you need to change font. Go to type/risolve missing font. Will open the same window in the pic you pasted. Then you find the font in the dropdown menu. I have to change all the Helvetica family ...it's a long go. If some one could save me. Hope to be usefull to your problem.

  • Is it possible to cache and index and not cache the table?

    can someone point me to the syntax? I have been messing with it and can't get the cache command on the indexes to work. I dont want to cache the table. Just the index blocks.

    i have to joins between tables with denormalized data and join non-unique columns. The indexes I am using have high clustering factors. i have no way of solving this right now.
    in performnace tests queries use a lot of physical IO and take a long time to return. If I run them a second time, they still use alot of logical IO, but return quickly. I have enough CPU to handle the logical IO and I need to speed up queries.
    I dont have enough memory to cache the tables data involved, but I do have enough to cache the indexes. When I run a 10046 trace virtually all of the work is done in the index searches, so I was hoping to cache the indexes in order to speed up the queries.
    again I can't solve the data issues and I am not concerned about the high logical IOs since there is limited concurrency and I have plenty of CPU.
    I guess my only other option is to find out which table in the join is would benefit most from caching and cache that table since these are big tables and I can really only cache one of them.

  • How to replace null value, if column is text and not numeric in OBIEE?

    Hi,
    Please note that I had tried to change the null text by adding bin value for Unspecified and Unknown but this did not work for me.. not sure if I am missing out to put anything in value filter…
    Thank You,
    Ravi

    Check this function:
    http://docs.oracle.com/cd/E23943_01/bi.1111/e10544/appsql.htm#CHDHJABI
    Cheers
    Nico
    IFNULL
    This function tests if an expression evaluates to a null value, and if it does, assigns the specified value to the expression.
    Syntax
    IFNULL(expr, value)
    Where:
    expr is the expression to evaluate.
    value is the value to assign if the expression evaluates to a null value.

  • Replacing 'word' in a string

    Hi! I want to replace Strings in a String, but if the the substring which has to be replaced is not a word, then i don't want it to be replaced. Eg.: I want to replace Words for other strings, where words are not substring of other Words :)
    Just want to ask if someone has made this before, and can help me out
    cu
    athalay

    But, my original question wasn't this. I
    want to replace words(string) for other strings in
    sentences(string). I hope it's clearer. So for example
    I have a sentence: This is an applepie. And if I want
    to replace apple for pear, then do not replace this
    sentence for pearpie, just remain it, because there's
    no "apple" word in this sentence. I hope it's clearer.
    My main problem is, that handling the First word of
    the sentence. It easy to replace " "+word+" " for what
    I want, but there are separatorchars like , . etc :)Search for the word you want to replace. Once you have found it, you will need to do a series of other checks...
    1) is it at the beginning or end of the sentence? (then you need to look at the character before or after the word depending on location in entire String to see if it is whitespace or separator character)
    2) is it surrounded by whitespace or separator characters on both sides? (get the surrounding characters and compare to a list of acceptable characters to make this a word, ie " ", ",", ";"...
    Only replace words that pass the conditions (beginning of sentence and followed by whitespace or separator, end of sentence and preceeded by whitespace or separator, or middle of sentence and surrounded by whitespace or separators).

  • RSRV - error - 0MATERIAL is in external and not internal forma

    Hi,
    When i do the RSRV for material in my system i get the following errors
    1) Value 0100001808  for char. 0MATERIAL is in external and not internal format
    2) Value in SID table 0109/ correct value 000000000000000109/ SID in SID table 57961
    how to resolve the errors ? any idea
    Regards,
    BWer

    Hello BWer,
    If you cannot make the change in OMSL, you will have to convert the material numbers in a transformation when loading.  As per note 555675, the settings in R/3 and BW must be identical.
    If the source is an SAP system, it is expected that the material number will have the correct format and the conversion exit will not be called.  If the settings are not the same as per note 555675, you will entounter problems.
    Best Regards,
    Vincent

  • Find and replace value in Delimited String

    Hi All,
    I have a requirement, where i need to find and replace values in delimited string.
    For example, the string is "GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~". The 4th column gives month and year. I need to replace it with previous month name. For example: "GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~". I need to do same for last 12 months.
    I thought of first devide the values and store it in variable and then after replacing it with required value, join it back.
    I just wanted to know if there is any better way to do it?

    for example (Assumption: the abbreviated month is the first occurance of 3 consecutive alphabetic charachters)
    with testdata as (
    select 'GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}') part
    ,to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}')
             ,to_char(add_months(to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY'),-1),'MON')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~
    FEB
    02/01/2013
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    with year included
    with testdata as (
    select 'GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}') part
    ,to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}')
             ,to_char(add_months(to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY'),-1),'MON-YY')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    JAN-13
    01/01/2013
    GL~1001~157747~DEC-12~CREDIT~A~N~USD~NULL~
    Message was edited by: chris227 year included

  • Process Message failed: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.

    Hi
    I am trying to process an X12 message and I am getting following error.
    Method : ProcessMessage
    Message : Process Message failed: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length
       at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
       at Q.Inbound.X12Preprocessor.getTranTypeFromFuncCode()
       at Q.Inbound.X12Preprocessor.setProcessType()
       at Q.Inbound.X12Preprocessor.getFuncGroupHeader(StreamReader sr)
       at Q.Inbound.X12Preprocessor.ProcessMessage(X12Definition& docInfo)
    Please help.
    Thanks

    Might try them over here.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral%2Cvbgeneral%2Cvcgeneral&filter=alltypes&sort=lastpostdesc
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Replace char on String

    Hi All,
    String strValue = "ABC TPT 0694";
    My String is as shown above, I am looking for a way to replace char at byte 6 (position 6) with another Char in String.
    For example at location 6 it is "T" I want to replace it with char "O". can any one tell me how to do this

    String strValue = "ABC TPT 0694";
    char[] chars = strValue.toCharArray();
    chars[5] = 'O';
    strValue = String.valueOf(chars);

  • Write string (7 chars), int16, sgl into binary file and read it in C

    How to write write string (7 chars), int16, sgl, string (5 chars) into binary file and then read it in C ?
    Total 18 Bytes file (binary) should be created.

    Hi,
    this could be done that way:
    You have to make sure the strings have their correct length!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Replacing chars in strings

    Here is the situation:
    int x=4
    char letter1='Z'
    String word1="blah blah"
    /code]
    I was wonering if the was an easy way of replacing a character in a string with another at a ceratin point in the string. In this case, I want a string that would say "blahZblah". Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Sure
    int x=4
    char letter1='Z'
    String word1="blah blah"
    [String word2 = word1.substring(0,x) + letter1 + word.substring(x + 1)[/b]

  • Query getting alphabetical neighbours of chars in a strings

    10gR2
    Hello,
    Can anybody give me a Select for getting the neighbour-chars (by Ascii-Code) of a simple source-string for a certain number of iterations?
    E.g. the source-string is "M" and the number of iterations is 7 then the Select's should give seven rows like:
    "M"
    "LM"
    "MN"
    "LMN"
    "KLM"
    "MNO"
    "KLMNO"
    "M" is the starting char; the next iteration gives the alphabetically preceding char "L" and concats with the starting char; the next iteration gives the alphabetical successor of the starting char (and concats it); the next iteration results the next the alphabetically preceding char of the most left-sided char of the last result; the next iteration gives the next alphabetical successor of the most right-sided char of the last iteration's result... and so on...
    2nd example, when starting with "DE":
    "DE"
    "CDE"
    "DEF".....
    Any ideas / hints ?

    Well, I don't see any business logic in that requirement, but here we go :
    SQL> var letter varchar2(10)
    SQL> var occ number
    SQL> exec :letter:='M'
    PL/SQL procedure successfully completed.
    SQL> exec :occ:=7
    PL/SQL procedure successfully completed.
    SQL> select str
      2  from   (select lvl,
      3                 decode(lv,1,(select replace(max(sys_connect_by_path(chr(ascii(letter)-(nb-level+1)),',')),',')||letter from dual connect by level <= nb),
      4                           2,letter||(select replace(max(sys_connect_by_path(chr(ascii(substr(letter,-1,1))+level),',')),',') from dual connect by level <= nb),
      5                             (select replace(max(sys_connect_by_path(chr(ascii(letter)-(nb-level+1)),',')),',')||letter from dual connect by level <= nb)
      6                             ||(select replace(max(sys_connect_by_path(chr(ascii(substr(letter,-1,1))+level),',')),',') from dual connect by level <= nb)) str
      7          from   (select letter, level lvl, mod(level,3) lv, sum(decode(mod(level,3),1,1)) over (order by level) nb
      8                  from   (select :letter letter, :occ occ from dual)
      9                  connect by level <= occ-1)
    10          where :occ > 1
    11          union all
    12          select 0,:letter from dual where :occ>0)
    13  order by lvl;
    STR
    M
    LM
    MN
    LMN
    KLM
    MNO
    KLMNO
    7 rows selected.
    SQL> exec :letter:='DE'
    PL/SQL procedure successfully completed.
    SQL> exec :occ:=3
    PL/SQL procedure successfully completed.
    SQL> /
    STR
    DE
    CDE
    DEF
    SQL> exec :letter:='DE'
    PL/SQL procedure successfully completed.
    SQL> exec :occ:=4
    PL/SQL procedure successfully completed.
    SQL> /
    STR
    DE
    CDE
    DEF
    CDEF
    SQL>Nicolas.
    adding a WHERE clauses to support occ=1 or occ=0
    Edited by: N. Gasparotto on Dec 22, 2008 4:34 PM

  • I want to replace "\" with "/" in a string.

    I tried this...
    String whatever = myString.replace("\\", "/");
    ...and this...
    String whatever = myString.replace("\", "/");
    ...but I get an error.
    I was able to get it to work doing it this way...
    String slashStr = "\\/";
    char slashArr[] = slashStr.toCharArray();
    whatever = whatever.replace(slashArr[0], slashArr[1]);
    But I think that is silly.
    Can someone tell me why the first method won't work?

    String whatever = myString.replace("\\", "/");
    String.replace
    ...and this...
    String whatever = myString.replace("\", "/");
    ...but I get an error.This is correct. There is no method String.replace(String,String)
    only String.replace(char,char)
    I was able to get it to work doing it this way...
    String slashStr = "\\/";
    char slashArr[] = slashStr.toCharArray();
    whatever = whatever.replace(slashArr[0], slashArr[1]);
    But I think that is silly.It is a bit.
    String s1 = "This\\Is\\The\\Original";
    String s2 = s1.replace('\\','/');
    ...Or something like that... Single quotes indicate a char literal
    - double-quotes indicate a string literal.
    Talden

Maybe you are looking for

  • Pagination woes

    Hi - wonder if anyone else has this problem...? I have three Framemaker book files. To simplify (and reduce the number of files, let's say I have: * Master book file file a file b file c file d * Book 1 file a file b file c * Book 2 file a file b fil

  • What's the deal when syncing to an iPhone? Unexpected results

    I'm new to Aperture, and have had odd issues when syncing selected Aperture albums through iTunes to my iPhone 3G. First, the photos appear in chronological order in Aperture 2, but are completely random when browsing the albums on my iPhone. Also, e

  • Crystal Reports Replacement?

    Im in the market to find what other companies are replacing Crystal Reports with. Im interested in some sort of PDF solution - but I want to know what other companies are using instead of Crysytal. Either a WYSIWYG editor for building reports and bin

  • Automated process to clear completed batches

    Hi , Can some one please explain how to clear completed batches in MDS automatically, I mean is there a sql code which we can execute using a  sql server agent job to clear the jobs. Thanks , Nagesh.

  • Why are my header icons and toolbar buttons grayed out?

    I purchased a used Macbook Pro from ebay.  Appeared to be in good working order when I first started working with it, but I have updated from OS X 10.9.2 to 10.9.5 and downloaded Open Office program, set up my mail and went through the system prefere