- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 01:57 AM - edited 03-14-2019 06:20 PM
Hello,
i get a "Double" Variable from a SQL Db that i convert to a string in order to split it.
but it's impossible to split with the point ( split"." ) .
did someone has an idea why is not working with the " . " because it's correctly working with " " and "-" ...etc
Solved! Go to Solution.
- Labels:
-
Other Contact Center
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 03:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 03:07 PM
"32.05".split("\.")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 03:10 PM
You need two backslashes "\\." not one, '\.' isn't a valid escape character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 10:06 AM
I used double quotes, and therefore do not need to escape the escape character in UCCX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 10:42 AM
You're totally right, good catch. This is a break from the java spec and appears to be a result of the statement itself stored as a string. This should probably be fixed in the parser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 12:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 03:08 PM - edited 07-12-2018 10:38 AM
Thats because myString.split(".") (notice the string quotes) uses regex to find the split with; in this case you'd want "\.".
You could simply convert your Double to an Integer and call it a day ( myDouble.intValue() );
HTH
Updated. Corrected from \\. to \. per Anthony Holoways comments. His statement is correct, even if it is incorrect java.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 10:53 AM
LOL to your edit.
Only, it's not Java.
It's technically a separate language all together, which Cisco dubs: Cisco UCCX Expression Language.
"Although the notation in the Expression Language is identical to Java in many cases, it is different in other cases. Also the Expression Language adds more support for creating literals of complex objects and more operators for these complex objects."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 11:39 AM
Having seen the parser, the expression language is absolutely based on Java with 'niceties' added in to make dealing with java objects simpler; for example, D[now] is a special literal type that translates simply to new java.util.Date(); not having to reference select class types by their canonical names, etc.
Best as I can tell the parser is based on Java 4 or 5 syntax grammars but is not a complete parser for the language. It's important to note that string literals are lazily parsed which is a real shame and why you cannot do something like String myString = "\"hello world\""; This is also why "305.05".split("\.") works as it is parsed into the pseudo structure:
Call( StringLiteral (305.05), "split", new Object[] { StringLiteral(\.) }) which essentially works out to executing the following code
String s1 = new String(new char[] { 51, 48, 53, 46, 48, 53 }); // bytes that represent the string "305.05" String s2 = new String(new char[] { 92, 46 }); // bytes that represent the string "\." java.lang.reflect.Method m = Class.forName("java.lang.String").getMethod("split", new Class [] { Class.forName("java.lang.String") } ); m.invoke(s1, new Object[] { s2 });
Could you argue that special language features outside of the java spec make it its own language? Perhaps, but lipstick on a pig is still a pig...
*shrug*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 06:19 PM
