Solved

match string ?

Posted on 2002-04-17
5
219 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can I clean log of  running tomcat 7 server ? 3 126
sortaSum challenge java 17 171
org.apache.jasper.JasperException: using jstl in jsp embedded jetty 13 602
java operators 3 114
Troubleshooting common task sequence error codes
Binary Differential Replication, What it is, how it works and how it differs from standard delta file replication
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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