Extracting the last N characters of a string 
Author Message
 Extracting the last N characters of a string

I'm using substr( -N ) to extract the last N characters of a string. This
works perfectly in NN4 -- and that is conforming to the NN docs too. But
in IE4 SP1 (4.72.3110.8) it does not work at all. It returns the entire
string :-(

Is there any other way than using the string's length, subtracting N+1 and
then using substr or substring from the resulting index?

Is NN (and its docs) in error or is IE in error?

--
Greetings from
 _____
 /_|__| Auke Reitsma, Delft, The Netherlands.
/  | \  -------------------------------------
        Remove SPAMBLOCK from my address ...



Wed, 04 Jun 2003 04:56:55 GMT  
 Extracting the last N characters of a string
It appears that Microsoft hasn't implemented the ECMA standard - according
to ECMA-262:

"If start is negative, it is treated as
(sourceLength+start) where sourceLength is the length of the string."

This is not implemented in JScript... (I'm using script v5.5).  So unless
you use RegExp or something else, then you're stuck.
Richard


Quote:
> I'm using substr( -N ) to extract the last N characters of a string. This
> works perfectly in NN4 -- and that is conforming to the NN docs too. But
> in IE4 SP1 (4.72.3110.8) it does not work at all. It returns the entire
> string :-(

> Is there any other way than using the string's length, subtracting N+1 and
> then using substr or substring from the resulting index?

> Is NN (and its docs) in error or is IE in error?

> --
> Greetings from
>  _____
>  /_|__| Auke Reitsma, Delft, The Netherlands.
> /  | \  -------------------------------------
>         Remove SPAMBLOCK from my address ...



Wed, 04 Jun 2003 11:10:04 GMT  
 Extracting the last N characters of a string
On Fri, 15 Dec 2000 21:10:04 -0600, "Richard A. Lowe"

Quote:

> It appears that Microsoft hasn't implemented the ECMA standard - according
> to ECMA-262:

> "If start is negative, it is treated as
> (sourceLength+start) where sourceLength is the length of the string."

So ECMA says NS is correct and MSIE is wrong. Good to know. I'm working on
a workaround that exacly implements that mentioned line from ECMA.

Quote:
> This is not implemented in JScript... (I'm using script v5.5).  So unless
> you use RegExp or something else, then you're stuck.
> Richard



> > I'm using substr( -N ) to extract the last N characters of a string. This
> > works perfectly in NN4 -- and that is conforming to the NN docs too. But
> > in IE4 SP1 (4.72.3110.8) it does not work at all. It returns the entire
> > string :-(

> > Is there any other way than using the string's length, subtracting N+1 and
> > then using substr or substring from the resulting index?

> > Is NN (and its docs) in error or is IE in error?

--
Greetings from
 _____
 /_|__| Auke Reitsma, Delft, The Netherlands.
/  | \  -------------------------------------
        Remove SPAMBLOCK from my address ...


Wed, 04 Jun 2003 20:29:50 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Remove last N characters from string

2. Remove last N characters from string

3. Works in NS, but not IE (Japanese Characters)

4. How to strip the 1st and last character out of a line of text

5. Extracting ASCII code from Characters

6. Extract a character path?

7. Finding Last name in a Full Name string.

8. Removing last word of string

9. Extract a string to a file

10. js : extract TITLE string from an HTML file openned with OpenAsTextStream

11. How do I extract prts of strings?

12. Extracting an [objects] name string

 

 
Powered by phpBB® Forum Software