Want the best way to trim a sting in javascript?
A while ago, I came across a post on such a subject. It was written a few years ago but it’s still as relevant and useful as ever.
Want the best way to trim a sting in javascript?
A while ago, I came across a post on such a subject. It was written a few years ago but it’s still as relevant and useful as ever.
Neat way of removing excess whitespace and tabbing from strings.
$string = "Tom\tThumb\t is sooooooo\t\t\tdumb"; $string = preg_replace( '/\s+/', ' ', $string ); echo $string; //will echo "Tom Thumb is sooooooo dumb"
Simple one. If you need to add/remove escape slashes to/from a string, use the following code.
Continue reading
If you have come across the cursed ‘Invalid Character‘ error while using PHP’s XML or JSON parser then you may be interested in this.
Continue reading
First off, regular expressions are great.
They are a handy quick way to validate or parse data and you can use them in almost all languages. But of all things, I forget neat regex’s and in fairness they are a pita to recall as the syntax is plain nutty.
This is where it ends. I am going to reference all the neat regex’s in this blog as I come across them rather than rely on mother Google.
Continue reading