title: How to encode letter from string into numbers
body: <p>what I am trying to do is encode numbers in a string into numbers acording to the alphabet an leave the numbers still. so "abc123" would be "123123". Found the solution in javascript but cannot seem to fit into java. any help would be great, thanks.</p>
  
  <p>The java function would be something like</p>
  
  <pre><code>import java.util.*; 
  import java.io.*;
  
  class Main {
  
    public static String NumberEncoding(String str) {
      ***call javascript function or translate it into java
    }
  
    public static void main (String[] args) {  
      // keep this function call here     
      Scanner s = new Scanner(System.in);
      System.out.print(NumberEncoding(s.nextLine())); 
    }
  
  }
  </code></pre>
  
  <p>The jasvascript function is</p>
  
  <pre><code>function NumberEncoding(str) { 
  str = str.toLowerCase();
  var obj = {};
  var alpha = "abcdefghijklmnopqrstuvwxyz";
  var result = "";
  for (var i = 1; i &lt;= alpha.length; i++) {
      obj[alpha[i-1]] = i;
  }
  
  for (var j = 0; j &lt; str.length; j++) {
    if (str[j].match(/[a-z]/)) {
      result += obj[str[j]];
    } else {
      result += str[j]; 
    }
  }
  return result;
  }
  </code></pre>