Validate an Email Address
6
PHP function to validate an email address.
7
I use this function when passing an array to a function being called from setTimeout();
12
Similar to Perl's CGI::escapeHTML(), though (because we can!) this adds it as a method to all String objects.
7
Turns any string backwards. If you input "Test" it gives out "tseT". Hope it's useful.
The snippet shows how to use it.
The snippet shows how to use it.
7
The modus operandi for this is similar to that taken by PHP's implementation of such functions. It's comparitively memory-intensive, but is much faster than running a whole bunch of tests.
Basically, you set a mask -- an array of 256 null bytes -- and set those that correspond to characters you wish to trim. Then, rather than having to test if a character is in the set of characters to trim(O(n), or linear time on *ws), you just test once (O(1), or unit time) to see if the byte in question is set.
And of course, to trim(), you just wrap trim() around both ltrim() and rtrim().
One point of caution: these functions trim in place, so copy strings before trimming them. (Of course, if you usually want access to both pre- and post-trimmed strings, you could always make these malloc() a new string and return a pointer to it . . . )
Basically, you set a mask -- an array of 256 null bytes -- and set those that correspond to characters you wish to trim. Then, rather than having to test if a character is in the set of characters to trim(O(n), or linear time on *ws), you just test once (O(1), or unit time) to see if the byte in question is set.
And of course, to trim(), you just wrap trim() around both ltrim() and rtrim().
One point of caution: these functions trim in place, so copy strings before trimming them. (Of course, if you usually want access to both pre- and post-trimmed strings, you could always make these malloc() a new string and return a pointer to it . . . )
9
Generates an 88 character secure hash string for the passed in strings.
7
A simple tool used for fast Exponentiation. Very useful if you are creating your own cryptograpgic methods.
6
A simple tool used for fast Exponentiation. Very useful if you are creating your own cryptograpgic methods.
2
This function loads an File into an String.
4
This function provides the reverse of a string. It is constructed using string builder because strings in .NET are immutable, while stringbuilders are not. Therefore large strings could be slow to reverse if a regular string was used for the working value that is returned.









