Solved

how to parse a String ?

Posted on 2004-04-28
2
196 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now