?
Solved

match string ?

Posted on 2002-04-17
5
Medium Priority
?
223 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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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