So... Regex. The Regex class makes use of what is known as a state automaton. If you want to learn more, (and I suggest that you should), you should check out the book Mastering Regular Expressions.
If you want to escape your input string to be checked via a regular expression, use this method. http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx As for your question, you should see it the other way round. You should NOT be looking to see if they are all caps, since obviously you can have other chars. So what you should do is make sure that there are no lower case. In Regex, the symbol ^ means NOT. Therefore you should check [^a-z]+ to make sure the character are not lower case, and [^A-Z]+ to make sure they are not upper case. You should use the .IsMatch method to make sure you are checking the whole input string. That should be enough to get you started. Hope that Helps, Reuben On 15 November 2011 18:41, William V <[email protected]> wrote: > I am trying to figure out how the MS Regular Expression class works, > currently I am using this class in PowerBuilder and I need to check > only text characters (not including #'s or special characters), if > they are either all uppercase or all lowercase(doesn't matter what > order). > > For example, 'TESTER$10', 'W10E7EE'. If all characters are Ucase, give > message and if all lowercase, give message. > > I have used many different combinations with no success. In addition I > have googled it and found different expressions, but they don't seem > to work or I am totally misunderstanding how this works. > > http://www.grymoire.com/Unix/Regular.html > > I have tried this: '^[A-Z]+$'. This works with only characters, but > once I add #'s or a special character it fails, > iole_regexp.Test( as_teststring ) returns false. > > Plus I have tried to use \w ('^\w[A-Z]+$') 'Match any word character' > but that doesn't work once I add a # or special symbol. > > I've tried this, '^(?=\w*[a-z])\w*$' , it works until I add a special > character. (tester12 works, tester$12 doesn't work). > > Any help would be much appreciated. > > Thanks > > -- > You received this message because you are subscribed to the Google > Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML > Web Services,.NET Remoting" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en > or visit the group website at http://megasolutions.net > -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net
