I am a JavaScript newbie with a Match() issue that I was hoping someone can help me with.
The string I am trying to match to is: ****[( S )][( I )]****
The code I have used to match the string is:
if (name.match([/\sS\s/])==[/\sS\s/]) return true;
It does not throw any errors, but it also does not match the string. Any and all assistance you can provide how I can code the above line, would be greatly appreciated.
The following is additional background and steps I took to try to resolve the problem:
The code is part of a function that works perfectly except for this line. Part of the other lines in this function are:
function skipchallenge(name)
{
if (name.match([/\sS\s/])==[/\sS\s/]) return true;
if (name.match("CLOSED")=="CLOSED") return true;
if (name.match("VOID")=="VOID") return true;
if (name.match("^WINNER")=="WINNER") return true;
return true;
}
Some of the lines that I have tried (more like grasping at straws ) include:
if (name.match([/\\sS\\s/])==[/\\sS\\s/]) return true;
if (name.match("\s(?=S)\s")=="\s(?=S)\s") return true;
if (name.match("\\s(?=S)\\s")=="\\s(?=S)\\s") return true;
if (name.match("' '(?=S)' '")=="' '(?=S)' '") return true;
if (name.match("\*{4}")=="\*{4}) return true;
if (name.match("\*\*\*\*\[\(")=="\*\*\*\*\[\(") return true;
if (name.match("\\sS\\s")=="\\sS\\s") return true;
if (name.match("S \)\]\[\( I")==("S \)\]\[\( I") return true;
Thank you Eric for your comments. I have been searching and reading the web for the past week and it has successfully gotten me through 590 lines of code. My only issue is this one line and I am finished. I am probably just missing it, but I just cannot figure out what I am doing wrong in this last piece. Any help anyone can provide with the proper syntax would be greatly appreciated.
function skipchallenge(name)
{
if (name.match(/\[\(\sS\s\)\]/) return true;
if (name.match("CLOSED")=="CLOSED") return true;
if (name.match("VOID")=="VOID") return true;
if (name.match("^WINNER")=="WINNER") return true;
return true;
}
Thank you Web_Bert for the suggestion. Unfortunately it did not work. I did add a final ) before the "return true" (to close the if "("), but it still did not work.
I have continued to read on expressions and cannot figure out why something like the following does not work:
if (name.match(/\sS\s/)) return true;
If any one can shed light why the above does not work or provide suggestions as to what might work, it would be greatly appreciated.
Bookmarks