Skip to content
Advertisement

replaceFirst , Why can’t special symbols be replaced?

replaceFirst , Why can’t special symbols be replaced? System.out.println(cal); // 1 * 1 + 1 <==== ??? Answer Special symbols which are used in the regular expressions need to be either escaped using or entire expression should be treated as a string literal with the help of Pattern.quote which basically surrounds the regex with the pair of Q and

How to speed up moveRows script

I use a script how move rows in other sheet and delete them if condition match. It works but sometimes it’s long. How can i speed up this please ? I try this but it’s not working. I think i can’t combine sh1.getRange(sh1.getLastRow()+1, 1,vals.lenght , vals[0].length).setValues(result) with sh0.deleteRows(i+1) or the problem is for (var i=vals.lenght-1;i>0;i–) ?? Answer I believe your

How do I prevent a long overflow?

My assignment ask us to ask the user to enter a number and print the factorial of it, it also ask us to not allow the user to chose any negative number or number over 25, when they do, we loop them back to scanner to re renter a number we were also told to store the number in a

Java PrintStream .println() method not outputting to file?

I am trying to write a method which recursively gathers data from files, and writes erroneous data to an error file. See code block: However, the error file is always blank. I’ve tried calling the .flush() and .close() methods. System.err is outputting so I know the code is being run. I’ve tried instantiating the PrintStream outside of the try-with-resources, no

Java formatting GMT Date

I’m not finding a way to do edit GMT Date I receive “params.date” one string in this format “yyyyMMdd”, so this is my flow: output: And I need it: Can someone help me? Answer A few important points: Thu Nov 17 21:00:00 GMT-03:00 2022 is not equal to Thu Nov 17 21:00:00 GMT-00:00 2022. The date-time of Thu Nov 17

Regex for adding a word to a specific line if line does not contain the word

I have a YAML file with multiple lines and I know there’s one line that looks like this: Note that there is unknown number of whitespaces at the beginning of this line (because YAML). The line can be identified uniquely by the schemas: expression. The number of existing values for the schemas property is unknown, but greater than zero. And

Advertisement