Results 1 to 2 of 2
  1. #1
    wprjr is offline Member
    Join Date
    May 2008
    Rep Power

    Default replacing last comma in a string with the word "or"


    This is my first post (and probably not my last!). I am just getting back to JSP, JSTL in particular, after being away from minor dabbling in it six years ago. I guess I'm practically a noob, so might as well start of with a good question...

    I have a variable containing the string "a,b,c,d,e."

    I need to replace the last "," with the word "or" (i.e. "a,b,c,d,e" becomes "a,b,c,d or e").

    I know fn:indexOf is probably the best solution, but I have no clue as to the entire syntax of making this happen. Any help is greatly appreciated.



  2. #2
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Rep Power


    You can use String.lastIndexOf() or one of the String.replace(...) with a regular expression. Here is the syntax: String (Java Platform SE 6)
    Daniel @ []
    Language is froth on the surface of thought

Similar Threads

  1. Hwlp with "Open", "Save", "Save as..."
    By trill in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 10:26 AM
  2. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 04:42 AM
  3. Replies: 1
    Last Post: 03-14-2008, 03:51 PM
  4. Replies: 1
    Last Post: 07-27-2007, 11:59 PM
  5. Replies: 1
    Last Post: 07-16-2007, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts