# Need help with this one-liner

**URL:** <https://forum.kirupa.com/t/need-help-with-this-one-liner/210826>\
**Category:** Uncategorized\
**Created:** [December 22, 2006, 2:57pm UTC](https://forum.kirupa.com/t/need-help-with-this-one-liner/210826 "2006-12-22T14:57:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duder78](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@duder78](https://forum.kirupa.com/u/duder78)\
**Post date:** [December 22, 2006, 2:57pm UTC](https://forum.kirupa.com/t/need-help-with-this-one-liner/210826/1 "2006-12-22T14:57:12Z")

</div>

Hey guys,

I’m working closely with our resident intern web developer and he’s supplying code for field validation within flash 8. After commenting out a few lines, i’ve determined that the following line is causing the script to blow up :

```auto
 
var remainder = String(str).substr(iLen, iLen – lastIndexOfDot);

```

Looking in the Flash 8 help files, I found that the original ‘substring’ has been deprecated as of Flash 5 so I plugged in the now commonly-used ‘substr’. When I run a syntax check on the code I get 14 actionscript errors with the first error being 'expecting a ( or a , ’ on the line which the snippet above is located. Here’s the whole function i’m using for clarity sake :

```auto
 
function validateEmail( str, f) : Boolean
{
indexOfAt = str.indexOf("@");
lastIndexOfDot = str.lastIndexOf(".");
var iLen = String(str).length;
var remainder = String(str).substr(iLen, iLen – lastIndexOfDot);
 if (indexOfAt !=-1 && lastIndexOfDot !=-1){
  if (lastIndexOfDot <indexOfAt) {
   trace(f + " email is invalid");
   return false;
  }
  else if String(remainder).length < 2 {
   trace(f + " email is invalid");
   return false;
  }
  else {
   trace(f + " email seems okay");
      return true;
  }
 }
 else {
  trace(f + " email is invalid");
  return false;
 }
}

```

Not the most bullet-proof email validation, but it will serve our needs well enough for what it’s being used for. Any idea why Flash 8 isn’t liking this small block of code?
