carriage return line feed testing 
Author Message
 carriage return line feed testing

can anyone help me test a string for CrLf?

I have:

if (s.indexOf("\r\f")){
alert("found CrLf");

Quote:
}

TIA

-TH



Thu, 24 Jul 2003 10:59:15 GMT  
 carriage return line feed testing
The indexOf("whatever") function will return a -1 if it doesn't find an
occurrance of the string you supply it.  So your if statement is probably
going to be running when you don't want it to.  An if condition may
understand a -1 to be a true value and therefore run whatever is in the
brackets.  You could try something like:

if (s.indexOf("\r\f") >= 0) { ..... }

Another thing, if you're looking for CrLf your escape characters should be
"\r\n" instead of "\r\f" (i think).  "\f" is a form feed which I don't think
is the same thing as a new line "\n".

hope that helps

michael


Quote:
> can anyone help me test a string for CrLf?

> I have:

> if (s.indexOf("\r\f")){
> alert("found CrLf");
> }

> TIA

> -TH



Thu, 24 Jul 2003 12:04:02 GMT  
 carriage return line feed testing
Thanks Mike.  I wasn't sure just how the CrLf was interpreted by javascript
...

-TH


Quote:
> The indexOf("whatever") function will return a -1 if it doesn't find an
> occurrance of the string you supply it.  So your if statement is probably
> going to be running when you don't want it to.  An if condition may
> understand a -1 to be a true value and therefore run whatever is in the
> brackets.  You could try something like:

> if (s.indexOf("\r\f") >= 0) { ..... }

> Another thing, if you're looking for CrLf your escape characters should be
> "\r\n" instead of "\r\f" (i think).  "\f" is a form feed which I don't
think
> is the same thing as a new line "\n".

> hope that helps

> michael



> > can anyone help me test a string for CrLf?

> > I have:

> > if (s.indexOf("\r\f")){
> > alert("found CrLf");
> > }

> > TIA

> > -TH



Fri, 25 Jul 2003 06:22:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. carriage returns + line feed

2. How do you remove line feed and carriage return values from a string

3. Carriage return / Line feed

4. Carriage Return/Line Feed?

5. Carriage return - line feed

6. saving carriage returns/line feeds when entering a form.

7. carriage return in mailto doesn't work

8. Carriage Returns in strings

9. How to substitute carriage returns?

10. TextArea - Carriage Return

11. Carriage Return in JS String

12. Hard Carriage Return

 

 
Powered by phpBB® Forum Software