1

I am trying to write a simple function to test whether a value is an integer or not in a CasperJS script however it keeps giving me Syntax Error. The function in question is the following:

function isInteger(possibleInteger) {
    var intMatchPattern = new RegExp("/^[\d]+$/");
    return intMatchPattern.test(possibleInteger)​;
}

I see nothing wrong with this function however CasperJS refuses to work until I remove the line with ".test" on it.

Is this a known CasperJS bug (Currently using the latest 1.1.0-DEV)? Or maybe a PhantomJS bug?

1 Answer 1

2

You have an invisible character before the last semicolon.

You can spot this character if you copy/paste your code, for example, in vim or if you tell your editor to show hidden characters.

If you remove this character your code should run fineenter image description here.

I found it out because pasting your code in Chrome javascript console I got the same error as in PhantomJS, rewriting your code by hand I didn't get any error.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow would you look at that. Strangely enough I dont see the character even when copying from my own code above however a rewrite seems to have done the job. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.