Solved

how to parse a String ?

Posted on 2004-04-28
2
198 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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 47
maven j2ee examles 2 60
How to return JSON response to ajax call in strut2 action class with SUCCESS result 2 179
jdbc error in jsp application 20 63
Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

791 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