|
-
Mar 7th, 2007, 10:38 AM
#1
Thread Starter
Addicted Member
if statement
if i have the following array:
Code:
private string[] digits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
and i then want to check if a string contains any of these numbers, could i do something like this:
Code:
String test ="1+2+3";
if(test equals any of the digits in 'digits')
{
// Do stuff
}
-
Mar 7th, 2007, 10:57 AM
#2
Lively Member
Re: if statement
i would use regular expressions
you need to add the following
Code:
using System.Text.RegularExpressions;
the actual code would be:
Code:
String strInput = "Your input text!!!11";
string strPatern = "[0-9]";
Match myMatch = Regex.Match(strInput, strPatern);
if(myMatch.Success)
{
//dostuff
}
-
Mar 7th, 2007, 11:00 AM
#3
Thread Starter
Addicted Member
Re: if statement
Thanks ill try it out
-
Mar 7th, 2007, 11:02 AM
#4
Thread Starter
Addicted Member
Re: if statement
Just ran into a snare...how about + - and *??
-
Mar 7th, 2007, 11:34 AM
#5
Lively Member
Re: if statement
 Originally Posted by carstenht
Just ran into a snare...how about + - and *??
think i answered that in your other thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|