Inserting the "enter" character in a String

Hi,
I would like to insert a "enter" character in a String to create a new line.
something like this
String test = "teste" + char(10) + "teste";
Thanks in advanced
Ricardo

Are you trying to do this in an email? You didn't mention that. If your email encoding doesn't support new lines (the most simple encoding doesn't) you can't send them. I don't know why you'd get those results though, unless you actually put "\\n\\r" in the Java program.
Anyway, it's not "my solution" it's just a fact. '\n' is the newline character and '\r' is the carriage return character.

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);

  • How we can find the last character in a string(Urgent Plz!)

    Gurus!
    How we can find the last character in a string.
    e.g i have a string say "Str" with value "10-01".
    Now i want to find the last character in "Str" i.e "ONE=1".
    i am using Oracle developer 6i with Oracle 8i(1.7).
    Plz help!
    Many thanks!

    Use the substr() and length() functions -
    x := '10-01';
    y := substr(x, length(x));

  • 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

  • Testing the last character of a string using .endsWith

    Hi,
    I want to check to see if the last character of a string is '@'.
    I tried if (StringAt.endsWith("a")) {
    but got no results.
    Is this the correct way to do it or is there another way.
    Thanks.
    Adam

    javadocs:
    String's endsWith method takes a string argument.
    endsWith
         public boolean endsWith(String suffix)
              Tests if this string ends with the specified suffix.
              Parameters:
                   suffix - the suffix.
              Returns:
                   true if the character sequence represented by the argument is a suffix of the character sequence
                   represented by this object; false otherwise. Note that the result will be true if the argument is the
                   empty string or is equal to this String object as determined by the equals(Object) method.
              Throws:
                   NullPointerException - if suffix is null.

  • Insert set of character in a string

    hi guys,
    I have created a string of length 19, i need to insert set of character and compare them if its right format or not.That is for barcode i need. i WANT MY PROGRAM TO GENERATE THIS FORMAT BARCODE.
    eg : INV40602007RE000155

    Hi
    SEARCH
    Variants:
    1. SEARCH f    FOR g.
    2. SEARCH itab FOR g.
    Note
    Like all string processsing statements, you can only use character-type operands here.
    If the type of an operand is not STRING, the operand is treated like a type C field, regardless of its actual type, even though no actual conversion takes place.
    See Only character fields allowed in string processing.
    Variant 1
    SEARCH f FOR g.
    Additions:
    1. ... ABBREVIATED
    2. ... STARTING AT n1
    3. ... ENDING   AT n2
    4. ... AND MARK
    Effect
    Searches the contents of f for the string in the field g. This string can have any of the following formats:
    'str'
    a character string (trailing spaces are ignored)
    '.str.'
    any character string between the periods
    '*str'
    a word ending with "str", including "str"
    'str*'
    a word beginning with "str", including "str"
    You can use any non-alphanumeric character as a separator, that is, spaces, punctuation marks and non-printable characters.
    Note
    The search patterns 'str' and '.str.' are identical apart from a few exceptions. You must use '.str.' when the pattern str contains spaces (at the end), the '.' character (at the beginning and end), or the '*' character (at the end). You should also use '.str.' when the contents of the search string str is a variable, since you cannot predict when you write the statement what the contents of the string will be.
    The system does not distinguish between upper and lower case characters.
    The return code is set as follows:
    SY-SUBRC = 0:
    The search string g was found in the field f. SY-FDPOS contains the offset of the found string or the found word within the field.
    SY-SUBRC = 4:
    The search string g was not found in the field f.
    Addition 1
    ... ABBREVIATED
    Effect
    Searches the field f for a word containing the character string specified in the field. Here, the characters specified in g may be separated by other characters in the word. If the string g occurs in a word, the return code in system field SY-SUBRC is set to 0. The first letter of the search string g and of the word must match.
    Example
    DATA F(50).
    MOVE 'Alaska Texas California' TO F.
    SEARCH F FOR 'Clfrn' ABBREVIATED.
    Here, SY-SUBRC is set to 0, since not only does the string 'Clfrn' occur (separated by other characters) in 'California', but 'Clfrn' and 'California' begin with the same letter.
    Addition 2
    ... STARTING AT n1
    Effect
    Searches the field f starting from the position n1. Here, n1 can also be a field containing the corresponding value. The first character in the field f is in position 1.
    When you use the addition STARTING AT, the position specified for the found pattern in SY-FDPOS does not refer to the start of the field, but to the position n1.
    Addition 3
    ... ENDING AT n2
    Effect
    Searches the field f up to the position n2.
    Addition 4
    ... AND MARK
    Effect
    If the search string g is found, all the characters of the search string and all the characters occurring in between (in the case of SEARCH ABBREVIATED) are converted to upper case in the field f.
    Example
    DATA F(20) VALUE 'Peter Paul Mary'.
    SEARCH F FOR '*UL' AND MARK.
    SY-SUBRC is now set to 0, since the search string was found in 'Paul'. SY-FDPOS has the value 6, since the character string found starts at the offset 6. Also, the search string is marked, so that the new contents of f are as follows:
    'Peter PAUL Mary'
    Variant 2
    SEARCH itab FOR g.
    Additions:
    1. ... ABBREVIATED
    2. ... STARTING AT line1
    3. ... ENDING   AT line2
    4. ... AND MARK
    Effect
    Searches the internal table itab for the string in field g. The string can have the same format as in variant 1. The value of SY-SUBRC is set to 0, if the search string is found in the table. The system field SY-TABIX then contains the number of the table line where the string was found. Meanwhile, SY-FDPOS specifies the offset of the found string within the table line.
    Note
    The statement does not search the header line of an internal table itab.
    Addition 1
    ... ABBREVIATED
    Effect
    As with SEARCH ABBREVIATED, searches the internal table itab for a word that contains the character string specified in the field g. Here, the characters specified in g can be separated by other characters in the word. The return code value of the system field SY-SUBRC is set to 0, if the string g occurs in a word. The first letter of the search string g and of the word must match.
    Addition 2
    ... STARTING AT line1
    Effect
    Searches the internal table itab starting from line line1 to the end. line1 can be a field that contains the corresponding values.
    Addition 3
    ... ENDING AT line2
    Effect
    Searches the internal table itab up to the line line2.
    Addition 4
    ... AND MARK
    Effect
    If the search string g is found, all the characters of that search string and all the characters occurring in between (in the case of SEARCH ABBREVIATED) are converted to upper case in the internal table itab.
    Example
    Let T be an internal table which is empty:
    TYPES: BEGIN OF T_TYPE,
            LINE(80),
          END OF T_TYPE.
    DATA: T TYPE STANDARD TABLE OF T_TYPE WITH
                 NON-UNIQUE DEFAULT KEY,
          WA_T TYPE T_TYPE.
    MOVE 'Alaska Texas       ' TO WA_T.
    APPEND WA_T TO T.
    MOVE 'California Arizona ' TO WA_T.
    APPEND WA_T TO T.
    SEARCH T FOR '*ONA' AND MARK.
    SY-SUBRC is now set to 0 because the search string was found in 'Arizona'. SY-TABIX contains the value 2 because 'Arizona' appears in the second line of the table T. SY-FDPOS is set to 11 because the found character string begins at the offset 11. Also, the search string was marked in the second line in such a way that the contents of that line now look as follows:
    'California ARIZONA'
    Note
    Performance:
    Searching generically for a string in an internal table is much more runtime-intensive (approx. 5000 msn (standardized microseconds)) than searching for 'str' (approx. 20 msn). This was measured using a table with 200 entries and 10 fields.
    If you perform a search in a field which is 50 bytes long for 'str' or 'str', the runtime consumption is approx. 300 msn, whereas searching for 'str' takes about 15 msn.
    Regards,
    Raghav

  • Want to single out the last character of a string

    There is a field where there are many strings of varying length. E.g.: AB001XUV, AB003XUK, DJ8933FXUV etc.
    From these strings I need to create a virtual column where only the last character is shown. So it shall be V, K, V for values from the above example.
    Can anyone please suggest me how to achieve this.
    Regards
    Hawker

    SQL> with t as (
      2  select 'AB001XUV' col from dual
      3  union
      4  select 'AB003XUK' col from dual
      5  union
      6  select 'DJ8933FXUV' col from dual
      7  )
      8  select substr(col,-1,1) from t
      9  /
    S
    V
    K
    V
    SQL> create table temp(id number,
                      col varchar2(10),
                      VIRTUAL_COL VARCHAR2(1)   GENERATED ALWAYS AS (substr(col,-1,1)) VIRTUAL
    SQL> insert into temp(id,col) values(1, 'AB001XUV') ;
    SQL> select * from temp ;
            ID COL        V
             1 AB001XUV   V
    SQL> Edited by: Azhar Husain on Aug 16, 2011 1:17 PM

  • How do I insert the tab character in a table cell in Pages 5.2?

    I'm typing text in a table cell.  I need to insert a tab in the text.  I've tried all of the modifier keys with the tab.  I read somewhere it would be CTRL>TAB, like Word, but that navigates to the Inspector.

    You will need to add a Unicode keyboard. System Preferences > Keyboard > Input Sources. Click the + button in the lower left. Scroll all the way to the end and select Others > Unicode Hex Input. Select and Add this. Check the box that says Show input menu in menu bar. Exit System Preferences.
    From the Finder menu, select your recent Unicode Hex Input source (it is a black box with white U+ in it). Now, position your cursor in your table cell between the characters where you want to insert a tab character. Press and hold your option key, then type 0009 (zeroes). This is the Unicode sequence for the tab control character. Space will open in your text. Tabs in table cells survive PDF export. The tab mark will not appear with Show invisibles enabled.
    Switch back to your normal country input source in that Finder input source menu.

  • The last character of a string

    How to judge the last char of a string is " ?
    if (s.endsWith("""))or
    if (s.endsWith("/""))

    bet
    you just copied and pasted what the OP had written
    and quickly put that
    backslash in, hit post without previewing first just
    to make me look like
    a slow old sod! It's not fair ;-)
    kind regards,
    JosNope, I used the Alt-[numeric code] combinations to manually type each character. Cut-n-paste is for wimps, and actually typing single-stroke keys is for milquetoasts.
    Alt-[numeric code] is for real men ;-)

  • How to get the numeric character in a string

    Hi Experts,
    I have the following requirement.
    I am double clicking on the number of a string and I need to get the number as the output.
    I have string  like
    String1 : "Account Number 19292 is closed"  I am double clicking on 19292
    I want the output as 19292
    String2 : "AccountNumber19292isclosed"   I am double clicking on 19292
    I want the output as 19292
    String3: "Account Number1929 2 isclosed"  I am double clicking on 1929
    I want the output as 1929 and not 19292
    String4 :"Account Number 1929 2is closed" I am double clicking on 2
    I want the output as 2.
    Thanks in Advance,
    Raju

    Hi Raju,
    All possible solutions should more or less do the following two steps:
    <ol>
    <li>Check if at the given offset is a number: If yes, retain all consecutive numeric characters from the offset; otherwise stop.</li>
    <li>Retain any consecutive numeric characters preceding the number at the given offset and remove all other characters</li>
    </ol>
    Pretty trivial stuff, but the interesting challenge is actually to come up with the solution with least amount of coding (and ideally still understandable). I have a solution that is pretty short, though not really obvious for people not knowing about regular expressions...
    So here's the coding (relevant part in the form) and a quick test harness to check out what it does:
    data:
    TXT type STRING,
    NUM type STRING,
    OFF type I,
    LEN type I.
    TXT = '0Account12 Number 345 6 78isclosed9.9'.
    LEN = strlen( TXT ).
    do LEN times.
      OFF = SY-INDEX - 1.
      perform EXTRACT_NUMBER using    TXT
                                      OFF
                             changing NUM.
      write: /(3) OFF, ':', (5) NUM, TXT(OFF) inverse no-gap, TXT+OFF.
    enddo.
    * Return number at given offset in string (empty if no number present)
    form EXTRACT_NUMBER using    TXT        type STRING
                                 VALUE(OFF) type I
                        changing NUM        type STRING.
      NUM = TXT.
      replace regex '^(\d+).*$' in section offset OFF of NUM with '$1'.
      if SY-SUBRC = 0.
        replace regex '^.*[^\d](\d*)$' in NUM with '$1'.
      else.
        NUM = ''.
      endif.
    endform.
    I think this should match your requirements. Let's see if somebody comes up with a solution with less lines...
    Cheers, harald

  • 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).

  • How to find out the repeated character in a string value?

    Dear People,
    I want to trace out the names where a character occured more than once.for ex, i need o/p as
    ENAME
    ALLEN
    TURNER
    ADAMS
    In which all the above name consists of repeated characters.
    I use Oracle 10g and i tried using REGEXP say for ex,
    SELECT ENAME FROM EMP WHERE REGEXP_LIKE(ENAME,'L{2}');
    ENAME
    ALLEN
    MILLERbut this works only for single character.how to specify condition for any character?.pls suggest me.
    With Regards
    VIDS

    Here is one way you can use from version 10 upwards:
    SQL> with emp as
      2  ( select 7369 empno, 'SMITH' ename, 'CLERK' job, 7902 mgr, date '1980-12-17' hiredate, 800 sal, NULL comm, 20 deptno from dual union all
      3    select 7499, 'ALLEN', 'SALESMAN', 7698, date '1981-02-20', 1600, 300, 30 from dual union all
      4    select 7521, 'WARD', 'SALESMAN', 7698, date '1981-02-22', 1250, 500, 30 from dual union all
      5    select 7566, 'JONES', 'MANAGER', 7839, date '1981-04-02', 2975, NULL, 20 from dual union all
      6    select 7654, 'MARTIN', 'SALESMAN', 7698, date '1981-09-28', 1250, 1400, 30 from dual union all
      7    select 7698, 'BLAKE', 'MANAGER', 7839, date '1981-05-01', 2850, NULL, 30 from dual union all
      8    select 7782, 'CLARK', 'MANAGER', 7839, date '1981-06-09', 2450, NULL, 10 from dual union all
      9    select 7788, 'SCOTT', 'ANALYST', 7566, date '1982-12-09', 3000, NULL, 20 from dual union all
    10    select 7839, 'KING', 'PRESIDENT', NULL, date '1981-11-17', 5000, NULL, 10 from dual union all
    11    select 7844, 'TURNER', 'SALESMAN', 7698, date '1981-09-08', 1500, 0, 30 from dual union all
    12    select 7876, 'ADAMS', 'CLERK', 7788, date '1983-01-12', 1100, NULL, 20 from dual union all
    13    select 7900, 'JAMES', 'CLERK', 7698, date '1981-12-03', 950, NULL, 30 from dual union all
    14    select 7902, 'FORD', 'ANALYST', 7566, date '1981-12-03', 3000, NULL, 20 from dual union all
    15    select 7934, 'MILLER', 'CLERK', 7782, date '1982-01-23', 1300, NULL, 10 from dual
    16  )
    17  select ename
    18       , e
    19       , count(*)
    20    from ( select ename
    21                , e
    22             from emp
    23            model
    24                  return updated rows
    25                  partition by (ename)
    26                  dimension by (0 i)
    27                  measures (ename e)
    28                  ( e[for i from 1 to length(e[0]) increment 1] = substr(e[0],cv(i),1)
    29                  )
    30         )
    31   group by ename
    32       , e
    33  having count(*) > 1
    34  /
    ENAME  E        COUNT(*)
    SCOTT  T               2
    MILLER L               2
    ADAMS  A               2
    ALLEN  L               2
    TURNER R               2
    5 rows selected.Regards,
    Rob.

  • Count the repeated character in a string

    Hi Great Gurus,
    Please tell me how to know how many times a given character repeats in a string.
    Please mail me .
    Thanks Gurus,
    Rahul

    hi,
    same thread----
    Re: find number of occurances of a particular character
    data:  var1(30)  type c value 'ghghj#ghjgjgh#ghjghjg#ghjg#'.
    data : totcnt type i,
           cnt type i,
           v type c,
           n type i.
    cnt = strlen( var1 ).
    do cnt times.
    move var1+n(1) to v.
    if v eq '#'.
    totcnt = totcnt + 1.
    endif.
    n = n + 1.
    if n = cnt .
    exit.
    endif.
    enddo.
    write:/ 'No of #s', totcnt .
    Regards
    Reshma

  • Any easier way to replace the last character of a string?

    this is what I got:
    select SUBSTR('tjgb005dy_01_31_08',1,LENGTH('tjgb005dy_01_31_08')-1)||'1' from dual;
    tjgb005dy_01_31_01and I am not quite fond of it. it looks ugly and it is long.
    so, I wonder if you guys have better ideas?
    Thanks

    (Perhaps with replace there is no easier solution than the primary posted.)Well, look where I ended up...
    SQL> -- generating sample data:
    SQL> with t as ( select 'tjgb005dy_01_31_08' str from dual union
      2              select 'tjgb005dy_01_31_03' from dual union
      3              select '888888888888888888' from dual
      4            )
      5  --
      6  -- actual query
      7  --
      8  select str
      9  ,      case
    10           when substr(str, -1) = 8
    11           then
    12             substr(str, 1, length(str)-1)||'1'
    13           else
    14             str
    15         end
    16  from t;
    STR                CASEWHENSUBSTR(STR,-1)=8THENSU
    888888888888888888 888888888888888881
    tjgb005dy_01_31_03 tjgb005dy_01_31_03
    tjgb005dy_01_31_08 tjgb005dy_01_31_01Now I'm going to stay at the coffee-machine for the rest of the day... ;)

  • Insert Character in a String ?

    I am trying to insert the following character " / " to my string. It is printing out as 19990923. I want the output to print 1999/09/23
    I need some help with this problem. Thanks for any assistance.
    String[] s2 = eRecord.split(",");
    String stkSymbol1 = s2[0];
    String stkDate1 = s2[1];
    // int a = stkDate1.length() ;
    // buffer.insert(3," / ");
    // System.out.printf("\n%s\n\n" buffer.toString());
    System.out.println ("The Date for the last record is : "+ stkDate1); //

    The error message told you that you have not declare the variable buffer.
    If you really think you do, check if the declaration inside a conditional statement which is invalid.
    Post the code with code tags.

Maybe you are looking for