Results 1 to 2 of 2

Thread: remove non alphanumeric chars + output last 6 chars

  1. #1
    Join Date
    Jul 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default remove non alphanumeric chars + output last 6 chars

    I am looking for some help creating a script, ideally in JS if this is possible.

    Essentially the end user will paste a string of characters (varying in length anything from 11-18 characters) into a text box, then click a button which will remove any non alphanumeric characters and spaces and display the last 6 digits of the string.

    For example, the user pastes: 7/9684798- 3
    The output should be: 847983

    Any help would be great!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    var N='7/9684798- 3';
    N=N.replace(/\D/g,'');
    alert(N.substring(N.length-6));

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •