Solved

Removing a fixed number of characters from text string

Posted on 2004-03-22
12
399 Views
Last Modified: 2008-03-10
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
Comment
Question by:sjsharp80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 16

Accepted Solution

by:
jaysolomon earned 400 total points
ID: 10649347
<script type="text/javascript">
<!--
var str = "XX_Test";
document.write(str.substring(3));
// -->
</script>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10649402
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10649414
mine works in all browsers

:P
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 25

Expert Comment

by:devic
ID: 10649418
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
 
LVL 8

Expert Comment

by:william_jwd
ID: 10649433
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
 
LVL 25

Expert Comment

by:devic
ID: 10649448
4_Test

jay, here your example get "est" :)

0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10649457
no it is not devic

XX_Test with substring 3 = Test

Do You know for sure XX is Num?
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10649472
also you only show 1 num and the questioner show two X's

so XX
0
 
LVL 25

Expert Comment

by:devic
ID: 10649476
ach sorry, i understood that is number :)
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10649478
>>>Bascially I want to strip the first 3 characters from this string.
0
 

Author Comment

by:sjsharp80
ID: 10649958
Thanks Jay your first suggestion works perfectly

Cheers
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10650010
Glad to have helped and thanks for the A
jAy :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question