Solved

match string ?

Posted on 2002-04-17
5
222 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
[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
  • 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

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
We take a look at some of the most common obstacles that IT teams run into as they work relentlessly to keep all the alarms and sirens from going off at once.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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