Last post Mar 28, 2012 05:59 PM by humble-apprentice
Mar 27, 2012 02:20 PM|humble-apprentice|LINK
I'm trying to create a Regular Expression to only accept "/Controller/Action" strings and I came upt with this:
Now, when the code runs it throws a FormatException saying "Input string was not in a correct format." My string at this point is coming in empty. How can I only check once the property has a value or after trying to submit?
Mar 27, 2012 03:56 PM|francesco abbruzzese|LINK
I think your regular expression is wrong. You put the ^ symbol at the beginning of the [. Doyou know it negates? This meand that no char in the square bracke will be accepted. So probably you have to remove it. Moreover you have to put some repetition char,
that say that the gropu may repeat several times. I think you hae to substitute each [^a-zA-Z0-9] with [a-zA-Z0-9]+
Also this way it is not...perfectly correct since controller names cannot start with a digit...first chat cannot be a digit. Moreover they can contain an underscore too...
Mar 28, 2012 05:59 PM|humble-apprentice|LINK
I'm trying this and I'm still receiving the same exception: @"^/([A-Za-z]+)/([\w]+)$". Now when my action is called, it returns the property with @"/Controller/Action" instead of blank so that's not solving it either. The exception appears when the View
is called and the model trying to show the editor for my property.
Can you tell me what is wrong with my regular expression?