Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegEx.IsMatch doesn't
Message
From
30/08/2011 09:23:00
 
 
To
30/08/2011 09:21:05
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01522238
Message ID:
01522246
Views:
34
>Thanks very much Gregory! That seems to have done the trick.
>

For RegEx - any time


>>In addition - if the # in the format converts leading zeroes to spaces, the pattern has to be adjusted to match the leading spaces
>>
>>
>>@"^ *-?\d+(\.\d{2})?$"
>>
>>
>>
>>>The d in the regex expr has to escaped
>>>
>>>And come to think of it - the dot has to be escaped as well otherwise it would match any character
>>>
>>>in C#, I would write
>>>
>>>new System.Text.RegularExpressions.Regex(@"^-?\d+(\.\d{2})?$", System.Text.RegularExpressions.RegexOptions.None);
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>I'm trying to run some code I found on the net for use in an SSRS report. Here is the relevant bit:
>>>>
>>>>
Shared expr As New  _
>>>>System.Text.RegularExpressions.Regex("^-?d+(.d{2})?$", _
>>>>System.Text.RegularExpressions.RegexOptions.None)
>>>>
>>>>Public Function ExpandPrice(ByVal Price As Double, Optional ByVal pSeparator As String = ".") As String
>>>>
>>>>    Dim pPrice As String
>>>>    pPrice = FORMAT(Price, "##############.00")
>>>>
>>>>    Dim temp As New System.Text.StringBuilder()
>>>>    If Not expr.IsMatch(pPrice) Then
>>>>        ' temp.Append(pPrice) or whatever you want to do here 
>>>>        temp.Append("we got here")
>>>>    Else
>>>>
>>>>What I am getting back from this function is the text "we got here" when I pass 208.26 (or any other number for that matter) in. I don't know VB very well, nor the Regular Expressions stuff so would appreciate if anyone could point out why the passed in number is failing the IsMatch check.
>>>>
>>>>Thanks
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform