Solved

match string ?

Posted on 2002-04-17
5
216 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
Comment Utility
if (str.indexOf("567") != -1)
  return 0;
else
  return 1;
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Did that work for you?
0
 
LVL 6

Expert Comment

by:kotan
Comment Utility
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
Comment Utility
to return  0 or 1

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

Expert Comment

by:cheekycj
Comment Utility
Glad I could help and Thanx for the "A"
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

11 Experts available now in Live!

Get 1:1 Help Now