Jump to content

Problem with exec()

- - - - -

  • Please log in to reply
5 replies to this topic

#1
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 176 posts
I would be greatful if enyone could explain me why this piece of code produces error at bolded lines. First and second lines are executed corectly
  
    ...
    var confirmCodePattern = /g(b+)g/g;
    var confirmCodePatternOccurs = confirmCodePattern.exec(field.value);
    [B]alert("length: " + confirmCodePatternOccurs.length);
[/B]   [B] if (confirmCodePatternOccurs.length < 2){[/B]
        alert("Wrong format of confirm code");
        document.getElementById("row7").style.background = "#FF4040";
        return false;
    ...
    return true;


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What is the error message?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
If exec fails to match the string, it returns null. Maybe you get a nullpointer by that.

#4
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 176 posts
Actually, i don't know error message, because i code in simple text editor (i am new to javascript). Maybe you could recommend any good javascript IDE? I assume i get error in that line because code stops being executed

#5
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
The error should be shown in the browser.
press F12 and click the Script tab in IE.
CTRL+Shift+J in chrome.
And something else for firefox :P

#6
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 176 posts
I have figured out that i got error because i tried to find size of array which was null. Thanks for help




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users