Solved

how to parse a String ?

Posted on 2004-04-28
2
200 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

The goal of this blog is: - To define the incident management process - To go over the key elements of an incident management system - To look into incident alert management tools that integrate with ConnectWise.
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…

738 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