trying to see if the last character is a '>'......any suggestions

I already know how to check for the character


heres what I got

if (userData.getName().charAt(0)!='<' ) {


thank

Recommended Answers

All 10 Replies

Why not == '>' ?

Edit: And, of course not 0. Try userData.length() - 1.

userData.endsWith(">") perhaps?

Edit: yeah, charAt(userData.length()-1) works just as well

alright...let me check that out..I'll be back to let u know

getting illegal start of expression and ';' expected...Im sure it's something small..or I set it up wrong....take a look

<div id="contactInfo">
  <%
	if (userData.getName().charAt(0)!='<') || (userData.getName().charAt(userData.getName().length()-1)!='>' ) {
  %>    

	<span> <%=userData.getName()%> &#8226;</span>
<%}

%>

Check your parenthesis on the if() statement.

Check your parenthesis on the if() statement.

ok I opened up the if:

<div id="contactInfo">
  <%
	if (userData.getName().charAt(0)!='<' || userData.getName().charAt(userData.getName().length()-1)!='>' ) {
  %>    

	<span> <%=userData.getName()%> &#8226;</span>

if I put "<sample" for the name...nuthing shows up

but if I put"sample>"..it still displays the string

I would think you'd want an && condition there, not an ||.

if (!userData.getName().startsWith("<") && !userData.getName().endsWith(">") )
Member Avatar for iamthwee

This looks to me like the beginning of a html/xml parser of some kind. If I'm wrong well, there ya go.

If I'm not then perhaps you should start looking into regular expressions. As they will help you in the long run.

thanx man

appreciate the help Ezzaral...good lookin playa!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.