node.js string.replace doesn’t work?

According to the Javascript standard, String.replace isn’t supposed to modify the string itself. It just returns the modified string. You can refer to the Mozilla Developer Network documentation for more info. You can always just set the string to the modified value: variableABC = variableABC.replace(‘B’, ‘D’) Edit: The code given above is to only replace … Read more

What are all the escape characters?

You can find the full list here. \t Insert a tab in the text at this point. \b Insert a backspace in the text at this point. \n Insert a newline in the text at this point. \r Insert a carriage return in the text at this point. \f Insert a formfeed in the text … Read more

Change date format in a Java string

Use LocalDateTime#parse() (or ZonedDateTime#parse() if the string happens to contain a time zone part) to parse a String in a certain pattern into a LocalDateTime. Use LocalDateTime#format() (or ZonedDateTime#format()) to format a LocalDateTime into a String in a certain pattern. Or, when you’re not on Java 8 yet, use SimpleDateFormat#parse() to parse a String in a certain pattern into a Date. Use SimpleDateFormat#format() to format a Date into a String in a certain pattern. See also: Java string to date … Read more

Java string to date conversion

That’s the hard way, and those java.util.Date setter methods have been deprecated since Java 1.1 (1997). Moreover, the whole java.util.Date class was de-facto deprecated (discommended) since introduction of java.time API in Java 8 (2014). Simply format the date using DateTimeFormatter with a pattern matching the input string (the tutorial is available here). In your specific case of “January 2, 2010” as the input … Read more

How do I break a string in YAML over multiple lines?

Using yaml folded style. The indention in each line will be ignored. A line break will be inserted at the end. http://symfony.com/doc/current/components/yaml/yaml_format.html You can use the “block chomping indicator” to eliminate the trailing line break, as follows: In either case, each line break is replaced by a space. There are other control tools available as … Read more

Creating multiline strings in JavaScript

Update: ECMAScript 6 (ES6) introduces a new type of literal, namely template literals. They have many features, variable interpolation among others, but most importantly for this question, they can be multiline. A template literal is delimited by backticks: (Note: I’m not advocating to use HTML in strings) Browser support is OK, but you can use transpilers to be more … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)