hehehehehe!! No... none of us are nuts :) I said it worked co'z I know that
"\n" is for newline I replaced it with "\s" may be Robert made a typo error.
The IndexOf is working your right... I just made a mistake on how to use it,
again Robert gives me an Idea on how to use it. Thanks a lot guys!! your
such a nice person =)
-----Original Message-----
From: Greg Hill [mailto:ghill@s...]
Sent: Wednesday, November 21, 2001 5:42 AM
To: javascript
Subject: [javascript] RE: Locate a character on a string
I am confused.
First, Sidney says he can't get the indexOf method to find a space ("
") character in a string. I don't see why not. It works fine for me:
alert("Space is at = " + "This is a string, with spaces".indexOf(" "))
Then Robert tells Sidney to use a regular expression that matches a
newline ("\n") character in order to find a space character; and
Sidney says "Thanks...it worked."
Is this entire exchange nuts, or am I?
--Greg
>You are an angel my friend =) Thanks a lot its worked :)
>
>Regards
>Sidney
>
>-----Original Message-----
>From: Nyman, Robert [mailto:Robert.Nyman@i...]
>Sent: Tuesday, November 20, 2001 3:45 PM
>To: javascript
>Subject: [javascript] RE: Locate a character on a string
>
>
>I'd use regular expressions to do it.
>For instance, see more at: http://www.webreference.com/js/column5/
>
>
>var strSomething = "This is a string, with spaces";
>strSomething.search(/\n/) finds the first space, and returns an integer
with
>its position (-1 if it doesn't find it).
>strSomething.search(/\n/g) finds all the spaces.
>strSomething.match(/\n/) finds the first space, but the match method
returns
>an array (where the arrays first position is the matched string/character).
>
>
>/Robert
>
>
>
>-----Original Message-----
>From: Sidney James P. Fuerte [mailto:fuertsj1104@y...]
>Sent: den 20 november 2001 02:28
>To: javascript
>Subject: [javascript] Locate a character on a string
>
>
>Hi,
>
>I have a function that locates a space " " in a particular string, I
>already tried to use the MATCH and INDEXOF of its not working or it has an
>error. Is there any other function that I can use for locating a character
>in a string? I would really appreciate your help
>
>Thanks/Regards
>Sidney