Click to See Complete Forum and Search --> : How to parse a string?
mcameron
04-18-2007, 02:33 PM
I have a string in the HTML, and it looks like this: "DOMAIN\username". HOw can i break down this string so that i will end up with just "username". Also I am thinking of adding to that string so it will look something like this: "username@somedomain.com". Is it possible to do? :confused: I am not too sharp at html-ing, so any help would be greatly apreciated.
Thank you in advance.
-Mike C.
ray326
04-18-2007, 02:55 PM
This isn't HTML. It will either take Javascript on the browser or, better, server side language manipulation.
Tweak4
04-19-2007, 09:58 AM
The Javascript method would be as follows:
<script type="text/javascript">
var input = "DOMAIN\\username";
document.write(input + "<br>");
output = input.substr(input.indexOf("\\")+1);
document.write(output);
</script>
(note: backslashes must be escaped, or JS will choke)
But like Ray said, something server side would probably work better. The same code in PHP would be
<?php
$input = "DOMAIN\username";
echo $input . "<br>";
$output = substr($input,strpos($input,"\\")+1);
echo $output . "<br>";
?>