Solved

match string ?

Posted on 2002-04-17
5
218 Views
Last Modified: 2010-04-01
I have a str = "abcdef567jhg";

How do I match above string if it has 567, then return 0;
0
Comment
Question by:tanc02
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 total points
ID: 6948663
if (str.indexOf("567") != -1)
  return 0;
else
  return 1;
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6949003
Did that work for you?
0
 
LVL 6

Expert Comment

by:kotan
ID: 6949706
If you are us JDK1.4, try regular expressions.

str.matches(".*567.*");
This will return true if it matches this pattern.
0
 
LVL 6

Expert Comment

by:kotan
ID: 6949709
to return  0 or 1

return str.matches(".*567.*") ? 0 : 1;
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6954731
Glad I could help and Thanx for the "A"
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

Title # Comments Views Activity
form submissions on a web page 2 143
How to group array of objects ? 5 61
maven webservice projet error 6 80
equalIsNot  challenge 43 133
Facing problems with you memory card? Cannot access your memory card? All stored data, images, videos are lost? If these are your questions...than this small article might help you out in retrieving your lost or inaccessible data.
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

22 Experts available now in Live!

Get 1:1 Help Now