Solved

how to parse a String ?

Posted on 2004-04-28
2
201 Views
Last Modified: 2010-04-01
Hello,
I would like to parse this String -
dept/software/eng/bob/
 
or
dept/software/eng/


And the result ie the output should only be -
test

It would be great if I can use some taglib to get the last element ie-
bob or eng


Or if you can help me with some Java code to do this please


Thanks
awaiting a response!
0
Comment
Question by:sdesar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
mark-b earned 20 total points
ID: 10943928
String s = "dept/software/eng/bob/";
            
StringTokenizer st = new StringTokenizer( s, "/" );
String last=null;
            
while (st.hasMoreTokens() ) last = st.nextToken();
            
System.out.println( "Last=" + last );
0
 

Author Comment

by:sdesar
ID: 10944050
Awesome !
Thanks
here are the excellent points
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question