dsdavis Posted November 13, 2015 Posted November 13, 2015 Hi,I'm using Jaspersoft Studio 6.0, and have a field that contains an email address. I'd like to simply display the username, rather than the full email address. How can I strip everything from the @ to the end, so that I'm left with only the username? I assume I can do this with an expression in the "Text" properties for the field, but don't know what the expression would be. Any help would be appreciated! Doug
stasp Posted November 14, 2015 Posted November 14, 2015 Hi Doug,It should be possible to do by using java split() method. Something like this:$F{myEmailAddress}.split("@")[0]This method splits a string into array of strings. The expression above returns the first part of the string where "@" is a separator, which in your case should return username. - Stas
dsdavis Posted November 14, 2015 Author Posted November 14, 2015 Thank you, Stas! That worked like a charm!!!!
hozawa Posted November 14, 2015 Posted November 14, 2015 JasperReports by default just uses Java (can be switched to use other language such as Groovy) so you can just use any one line Java expression in your Text expression. See the following page for several ways to extract name from email address.http://stackoverflow.com/questions/7266608/how-can-i-extract-the-user-name-from-an-email-address-using-javascript
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now