Help with Java Strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashkash
    New Member
    • Jul 2006
    • 6

    Help with Java Strings

    I have strings in Java where each one is as follows: "Case Number XXX-XXX-XXX"
    The "XXX-XXX-XXX" part is different for each string. I want to just extract the "XXX-XXX-XXX" portion of each string. I am assuming this is the third token in the string. What would be the best way of doing this? thanks.
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Originally posted by ashkash
    I have strings in Java where each one is as follows: "Case Number XXX-XXX-XXX"
    The "XXX-XXX-XXX" part is different for each string. I want to just extract the "XXX-XXX-XXX" portion of each string. I am assuming this is the third token in the string. What would be the best way of doing this? thanks.
    If you know you want the substring starting at offset 12 (did I count correctly?), the simplest thing to do is use the String method substring: http://java.sun.com/javase/6/docs/api/

    Comment

    • ashkash
      New Member
      • Jul 2006
      • 6

      #3
      got it, thanks for your help.

      Comment

      Working...