jbariel Posted August 24, 2010 Share Posted August 24, 2010 I have a field that returns the full username from our IM server. The user name is in the format username@server/program. I would like the returned value to be limited to just the "username". Here is the expression I am using: $F{ofMessageArchive_A_fromJID}.replace("@.*","") This fails to replace anything. However, if I use:$F{ofMessageArchive_A_fromJID}.replace("@server/program","") it works just fine.is . or * not the correct wildcard in the explression editor? I've also tried single quotes, and escaping the @. I'm sure there are other methods to do this and I could do it in the SQL query, but mainly I need to know what wildcards work for future use. Thanks Code: Post Edited by jbariel at 08/24/2010 17:40 Link to comment Share on other sites More sharing options...
jbariel Posted August 24, 2010 Author Share Posted August 24, 2010 Seems replace(regexp, replacetext) does not with the wildcards, but replaceAll(regexp, replacetext) does. Link to comment Share on other sites More sharing options...
slow Posted August 25, 2010 Share Posted August 25, 2010 as you can see here:http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)the replace method works only with char sequence... so, the dot '.' means only a dot :)replaceAll works instead with regular expression... Link to comment Share on other sites More sharing options...
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