The method below matches all words that starts with a slash and no other slash should be found within the String. Using regex, I used a positive look behind approach that whenever a slash character is found, it should check if the previous character is a space character while the whole word should also be followed by a space character as well.

This way, the regex pattern ensures that the first chracter should be a slash and any characters following it are accepted such that there should be a space character at the end.

The regex does have a little limitation. What if the very first character of the String is a slash? Then it would not match that word because there is no previous space character before it. The only workaround for this one was to check if the String starts with a slash and if so, manually add a space character at the very first index of the String.

berner_leeHere is one tidbit that has me baffled. I read in some news that the forward slashes at the beginning of internet addresses (HTTP://) have long annoyed net users and now the man behind them has apologised for using them.

Sir Tim Berners-Lee, the creator of the World Wide Web, has confessed that the // in a web address were actually unnecessary, so he says. Why all the fuss? Users can just type in the domain URL without typing in http://, right?

He told the Times newspaper that he could easily have designed URLs not to have the forward slashes. He admitted that when he devised the web, almost 20 years ago, he had no idea that the forward slashes in every web address would cause “so much hassle”. Adding // would waste printing and paper but what the … those are just a few measly characters.

Frankly, this really does not have major effect. It is up to people to add http:// or not right? 😉

Related Posts Plugin for WordPress, Blogger...