• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

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
0
sjsharp80
Asked:
sjsharp80
1 Solution
 
jaysolomonCommented:
<script type="text/javascript">
<!--
var str = "XX_Test";
document.write(str.substring(3));
// -->
</script>
0
 
ZvonkoSystems architectCommented:
Check this:

<html>
<body onLoad="document.write(document.body.innerHTML.replace(/XX_/g,''))">
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>



0
 
jaysolomonCommented:
mine works in all browsers

:P
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
devicCommented:
Zvonko, i think must be this :)
===========
<html>
<body onLoad="document.write(document.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>
0
 
william_jwdCommented:
If you want to strip out anything before '_', then try this

<script type="text/javascript">
<!--
var str = "XX_Test";
document.write(str.substring(str.lastIndexOf('_') + 1));
// -->
</script>
0
 
devicCommented:
4_Test

jay, here your example get "est" :)

0
 
jaysolomonCommented:
no it is not devic

XX_Test with substring 3 = Test

Do You know for sure XX is Num?
0
 
jaysolomonCommented:
also you only show 1 num and the questioner show two X's

so XX
0
 
devicCommented:
ach sorry, i understood that is number :)
0
 
jaysolomonCommented:
>>>Bascially I want to strip the first 3 characters from this string.
0
 
sjsharp80Author Commented:
Thanks Jay your first suggestion works perfectly

Cheers
0
 
jaysolomonCommented:
Glad to have helped and thanks for the A
jAy :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now