iOS Audio Trimming

Here’s the code that I’ve used to trim audio from a pre-existing file. You’ll need to change the M4A related constants if you’ve saved or are saving to another format. – (BOOL)trimAudio { float vocalStartMarker = <starting time>; float vocalEndMarker = <ending time>; NSURL *audioFileInput = <your pre-existing file>; NSURL *audioFileOutput = <the file you … Read more

PHP ltrim behavior with character list

The second argument to ltrim is a list of characters to remove from the left side of the string. If you did <?php ltrim(‘lllliiiiaaaaaatttttt’, ‘mailto:’); ?> You would get an empty string as the return value. Try this instead: <?php $email=”mailto:[email protected]”; $fixedEmail = substr($email, 0, 7) == ‘mailto:’ ? substr($email, 7) : $email; ?>

Does swift have a trim method on String?

Here’s how you remove all the whitespace from the beginning and end of a String. (Example tested with Swift 2.0.) let myString = ” \t\t Let’s trim all the whitespace \n \t \n ” let trimmedString = myString.stringByTrimmingCharactersInSet( NSCharacterSet.whitespaceAndNewlineCharacterSet() ) // Returns “Let’s trim all the whitespace” (Example tested with Swift 3+.) let myString = … Read more

How to trim an std::string?

EDIT Since c++17, some parts of the standard library were removed. Fortunately, starting with c++11, we have lambdas which are a superior solution. #include <algorithm> #include <cctype> #include <locale> // trim from start (in place) static inline void ltrim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { return !std::isspace(ch); })); } // trim from … Read more

How to remove only trailing spaces of a string in Java and keep leading spaces?

Since JDK 11 If you are on JDK 11 or higher you should probably be using stripTrailing(). Earlier JDK versions Using the regular expression \s++$, you can replace all trailing space characters (includes space and tab characters) with the empty string (“”). final String text = ” foo “; System.out.println(text.replaceFirst(“\\s++$”, “”)); Output foo Online demo. … Read more

Trim trailing spaces with PostgreSQL

There are many different invisible characters. Many of them have the property WSpace=Y (“whitespace”) in Unicode. But some special characters are not considered “whitespace” and still have no visible representation. The excellent Wikipedia articles about space (punctuation) and whitespace characters should give you an idea. <rant>Unicode sucks in this regard: introducing lots of exotic characters … Read more