|
-
April 2nd, 2003, 11:37 PM
#1
way for string checking?
Is there any good way for string checking?
I want to check any exitances of some specific strings in the textbox, but I just know this method.
if (textbox1.Text.IndexOf("specific string ") > 0 )
MessageBox.Show("repeated! ", "Error Input",MessageBoxButtons.OK , MessageBoxIcon.Warning);
any best solution for that? I think mine is not a good way....
-
April 3rd, 2003, 12:43 AM
#2
well, your way sometimes doesn't work in case the string is positioned at the beginnen of the textbox.text
this is the right way:
Code:
if(textBox1.text.IndexOf(checktext) != -1)
{
//String found !
MessageBox.Show(checktext + " was found!","Text found",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
I don't know any other way to find a specific string in a string.
WM.
What about weapons of mass construction?
-
April 3rd, 2003, 11:39 AM
#3
depends upon what type of checking you are doing. if you are finding specific string then the usual way using IndexOf is Okay.
Suppose that you want to search some patterns
for example
your string is
"Blah Blah Blah 123 Blah @#$123"
now you want the digit occourences ,
you can do it by IndexOf by eXtra code is added.
using Regular Expressions you can search the patterns.
for more information you can check out MSDN for Regular Expressions.
Paresh
- Software Architect
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
|