Right Scott...
Dumb question it was indeed ;-)
Actually the problem I ran into did involve // found in a regular expression
that was generated by a regular expression builder.
Perhaps the expression generated was a mistake by the 3rd party program, but
I know I tried to paste it into a JavaScript function and it wouldn't work.
I will take more time to study regex and see if there is any case where I
would actually come across the occasion to use // in a regular expression. I
suspect there might be, possibly when doing a search match on a forward
slash.
I hope everyone got a good laugh over my mistake. I know I did.
[quoted text, click to view] "Scott M." <smar@nospam.nospam> wrote in message
news:%23ZKIvkFbIHA.5276@TK2MSFTNGP06.phx.gbl...
> Double forward-slashes (//) are comments in JavaScript. Double
> back-slashes (\\) are an escape code for a single back-slash.
>
> -Scott
>
>
> "John Kotuby" <johnk@powerlist.com> wrote in message
> news:uA7KqgFbIHA.1204@TK2MSFTNGP03.phx.gbl...
>> Hi all,
>>
>> I am trying to learn how to use regular expression objects in JavaScript.
>> I am missing some very basic JavaScript concept.
>> While playing around with regular expressions from a 3rd party regex
>> creator, I tried pasting a regex expression that contained \\ into a
>> JavaScript function which, of course, interpreted the double backslash as
>> a comment indicator.
>>
>> The JScript documentation states:
>> "Notice that because the backslash itself is used as the escape
>> character, you cannot directly type one in your script. If you want to
>> write a backslash, you must type two of them together (\\)."
>>
>> Also I have seen that to declare a regular expression object it is not
>> correct to use apostrophes or double quotes to delimit the expression.
>> For example...
>>
>> theRegExpObj=/(^\s*)|(\s*$)/g
>>
>> rather than
>>
>> theRegExpObj="/(^\s*)|(\s*$)/g"
>>
>> So back to my original question. How does one use \\ in a JavaScript
>> function if it is meant as an escape code for the backslash rather than
>> the beginning of a comment?
>>
>> Thanks for any answers.
>>
>>
>
>