Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top