Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

match string ?

I have a str = "abcdef567jhg";

How do I match above string if it has 567, then return 0;
0
tanc02
Asked:
tanc02
  • 3
  • 2
1 Solution
 
cheekycjCommented:
if (str.indexOf("567") != -1)
  return 0;
else
  return 1;
0
 
cheekycjCommented:
Did that work for you?
0
 
kotanCommented:
If you are us JDK1.4, try regular expressions.

str.matches(".*567.*");
This will return true if it matches this pattern.
0
 
kotanCommented:
to return  0 or 1

return str.matches(".*567.*") ? 0 : 1;
0
 
cheekycjCommented:
Glad I could help and Thanx for the "A"
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now