![]() |
|
[Java] Split text if it is longer than 640 characters - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Split text if it is longer than 640 characters (/showthread.php?tid=5600544) |
Split text if it is longer than 640 characters - beluga13 - Apr 15, 2017 Hey there, so I have written a code that returns a string which. What I want to do is to split it if the string is longer than 640 characters.. I have made three different routes depending on what I want to get returned. The data is collected from the pre written JSON. If you think you can help me figure this out I would be glad ?? Please PM me or post bellow if you can help me with that. I will share the code privately. Thanks in advance :) * - Weco - Apr 15, 2017 Code String data = ...* - beluga13 - Apr 15, 2017 (Apr 15, 2017 02:45 PM)Weco Wrote:Hey there, thanks for helping tho. But I don't think it will work.. The function returns a string which is XXX characters longs. Depending on a JSON data: Code function toMessage(item) {I want to split it into 2 or more separate messages if it is longer than 640 characters. * - Weco - Apr 15, 2017 (Apr 15, 2017 03:00 PM)Blaz Wrote: Hey there,Did you maybe confuse Java and JavaScript? 😊 * - beluga13 - Apr 16, 2017 (Apr 15, 2017 03:39 PM)Weco Wrote: Did you maybe confuse Java and JavaScript? 😊Yes probably.. Code is made in JavaScript ? (Apr 15, 2017 03:39 PM)Weco Wrote: Did you maybe confuse Java and JavaScript? 😊Yes probably.. Code is made in JavaScript ? * - Owl - Apr 16, 2017 Assuming javascript, here is my suggestion: Code var str = 'abcdefghij',It uses a length of 3 for demonstration and considers remainders. * - Weco - Apr 16, 2017 (Apr 16, 2017 03:43 AM)Blaz Wrote: Yes probably.. Code is made in JavaScript ?This section is for Java and not JavaScript​ (completely different languages) * - SIM-429621 - Apr 16, 2017 Hmm, try something like this, I'll write this code without IDE so bare with my indentation: Code Scanner in = new Scanner(System.in);OK just saw that you mistook Java and JS, here is JS version: Code // var string = prompt("Enter your string:"); <- random string that user enters* - Acteda - Apr 19, 2017 I havn't messed around with the code, but maybe do a method or something that keeps on repeating it, so if you have 1300 it checks it twice and splits it into three |