std::string to char*

It won’t automatically convert (thank god). You’ll have to use the method c_str() to get the C string version. Note that it returns a const char *; you aren’t allowed to change the C-style string returned by c_str(). If you want to process it you’ll have to copy it first: Or in modern C++:

How to replace all occurrences of a string in JavaScript

Update: In the latest versions of most popular browsers, you can use replaceAll as shown here: But check Can I use or another compatibility table first to make sure the browsers you’re targeting have added support for it first. For Node and compatibility with older/non-current browsers: Note: Don’t use the following solution in performance critical … Read more

How do I compare strings in Java?

== tests for reference equality (whether they are the same object). .equals() tests for value equality (whether they are logically “equal”). Objects.equals() checks for null before calling .equals() so you don’t have to (available as of JDK7, also available in Guava). Consequently, if you want to test whether two strings have the same value you … Read more

How to split a string in Java

Just use the appropriate method: String#split(). Note that this takes a regular expression, so remember to escape special characters if necessary. there are 12 characters with special meanings: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the … Read more