• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1363
  • Last Modified:

reporting service regular expression

Hi

http://msdn2.microsoft.com/en-us/library/ms157328.aspx

=System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value, "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3")

when i add the expression i get a squerrel underline at "Replace"

i think i need to add a reference but which ?

thanks
0
vbturbo
Asked:
vbturbo
  • 3
  • 3
1 Solution
 
PFrogCommented:
No, you can use it without a reference.
In tis instance the red squiggle is an SSRS problem, not a problem with your code - it can't parse the .Net framework and validae the function name at design time, so it squiggles. It does the same thing with custom code functions.
If you try and run the report it should work fine.
0
 
vbturboAuthor Commented:
Using this in my expression generation i just get errors down the column rows

'format and convert date to string
=CDate(Fields!udstedelsesdato.Value).ToString("dd-MM-yyyy")
'match all strings that is = 01-01-0001 and replace them with string = test
=System.Text.RegularExpressions.Regex.Replace(Fields!udstedelsesdato.Value, ("\b01-01-0001\b") , "test"))

where am i dropping the ball ?


0
 
vbturboAuthor Commented:
=System.Text.RegularExpressions.Regex.Replace(Fields!udstedelsesdato.Value, "\b01-01-0001\b" , "test").ToString()

produces this error : #Error

though i have validated the regex expression and it works fine
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
PFrogCommented:
You've got a few too many parenthesis in there, try this
  =System.Text.RegularExpressions.Regex.Replace(Fields!udstedelsesdato.Value, "\b01-01-0001\b", "test")

However, that assumes that your udstedelsesdato field is a string, formatted exactly as you expect. If you combine your two statements you get
  =System.Text.RegularExpressions.Regex.Replace(CDate(Fields!udstedelsesdato.Value).ToString("dd-MM-yyyy"), "\b01-01-0001\b", "test")

Which I think is what you're after
0
 
PFrogCommented:
Try using a proper date not in the year 0001
I think SSRS will generate a cast error as it doesn't recognise 0001 as a valid year
0
 
vbturboAuthor Commented:
<Try using a proper date not in the year 0001
<I think SSRS will generate a cast error as it doesn't recognise 0001 as a valid year

this is because its a null value.
but it get represented as "0001" in the report (01-01-0001)

but your expression works great....thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now