SubString Function

They have: 39 posts

Joined: Jun 2000

I have a long string, I need to retrieve the string 'Q10071'
Here is the string

if( top.getvar('customer_state')=='TX' ) {top.show_question('Q10071');}

Is it possible to do that?

Thanks!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

I'm confused. What does show_question() do? retrieve the string?
The following is the syntax for the subString method:

var x = someString.subString(start,end);

Vinny

Where the world once stood
the blades of grass cut me still

They have: 39 posts

Joined: Jun 2000

This is a long string which I am pulling from the database. I want to extract 'Q10070' from that long string

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

var sIndex = 0;
var eIndex = 'Q10070'.length; // 6
if('Q10070'.indexOf(LongString) != -1)
{
sIndex = 'Q10070'.indexOf(LongString)
Str2Right = LongString.subString(sIndex, sIndex + eIndex);
Str2Left = LongString.subString(0, sIndex);
}

If you would like some more, see the "String Functions" script/tutorial at my site.

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.