sjsharp80
asked on
Removing a fixed number of characters from text string
Hi,
I have the following text string on a page XX_Test, the program I am working with needs this format but when it is displayed in the browser I want it to just display Test, I want the format to be changed when the page loads.
Bascially I want to strip the first 3 characters from this string.
Thanks
I have the following text string on a page XX_Test, the program I am working with needs this format but when it is displayed in the browser I want it to just display Test, I want the format to be changed when the page loads.
Bascially I want to strip the first 3 characters from this string.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mine works in all browsers
:P
:P
Zvonko, i think must be this :)
===========
<html>
<body onLoad="document.write(doc ument.body .innerHTML .replace(/ [\d]{1,2}_ /g,''))">
Hi,
I have the following text string on a page 66_Test, 21_Test, 4_Test,the program I am working with needs this format but when it is displayed in the browser I want it to just display Test, I want the format to be changed when the page loads.
Bascially I want to strip the first 3 characters from this string.
Thanks
</body>
</html>
===========
<html>
<body onLoad="document.write(doc
Hi,
I have the following text string on a page 66_Test, 21_Test, 4_Test,the program I am working with needs this format but when it is displayed in the browser I want it to just display Test, I want the format to be changed when the page loads.
Bascially I want to strip the first 3 characters from this string.
Thanks
</body>
</html>
If you want to strip out anything before '_', then try this
<script type="text/javascript">
<!--
var str = "XX_Test";
document.write(str.substri ng(str.las tIndexOf(' _') + 1));
// -->
</script>
<script type="text/javascript">
<!--
var str = "XX_Test";
document.write(str.substri
// -->
</script>
4_Test
jay, here your example get "est" :)
jay, here your example get "est" :)
no it is not devic
XX_Test with substring 3 = Test
Do You know for sure XX is Num?
XX_Test with substring 3 = Test
Do You know for sure XX is Num?
also you only show 1 num and the questioner show two X's
so XX
so XX
ach sorry, i understood that is number :)
>>>Bascially I want to strip the first 3 characters from this string.
ASKER
Thanks Jay your first suggestion works perfectly
Cheers
Cheers
Glad to have helped and thanks for the A
jAy :)
jAy :)
<html>
<body onLoad="document.write(doc
Hi,
I have the following text string on a page XX_Test, the program I am working with needs this format but when it is displayed in the browser I want it to just display Test, I want the format to be changed when the page loads.
Bascially I want to strip the first 3 characters from this string.
Thanks
</body>
</html>