Question: I have two databases with different structure.

Table 1:

```
ch_code    ch_def    ch_weight

```

Table 2:

```
address    ch_code

```

I need to merge this two tables, so the structure would look like:

```
ch_code    ch_def    ch_weight    address

```

The number or rows in two tables are different (table 1 has more data).

Should I use `merge`, `union`.. something else?

Thank you!

Answer: 
```
var end = "24235235adasd_4.jpg".match(/.*_(.*)/)[1];

```

Edit: Whoops, the ungreedy modifier was wrong.

Edit 2: After running a benchmark, this is the slowest method. Don't use it ;) Here is the benchmark and the results.

**Benchmark:**

```
var MAX     = 100000,     i =  0, 
    s       = new Date(), e = new Date(), 
    str     = "24235235ad_as___4.jpg",
    methods = {
        "Matching":  function() { return str.match(/.*_(.*)/)[1];               },
        "Substr":    function() { return str.substr(str.lastIndexOf('_') + 1);  },
        "Split/pop": function() { return str.split('_').pop();                  },
        "Replace":   function() { return str.replace(/.*_/,'');                 }
    };

console.info("Each method over %d iterations", MAX);
for ( var m in methods ) {
    if ( !methods.hasOwnProperty(m) ) { continue; }
    i = 0;

    s = new Date();
    do {
        methods[m]();
    } while ( ++i<MAX );
    e = new Date();

    console.info(m);
    console.log("Result: '%s'", methods[m]());
    console.log("Total: %dms; average: %dms", +e - +s, (+e - +s) / MAX);
}

```

**Results:**

```
Each method over 100000 iterations
Matching
Result: '4.jpg'
Total: 1079ms; average: 0.01079ms
Substr
Result: '4.jpg'
Total: 371ms; average: 0.00371ms
Split/pop
Result: '4.jpg'
Total: 640ms; average: 0.0064ms
Replace
Result: '4.jpg'
Total: 596ms; average: 0.00596ms

```

[Gordon Tucker's Substr/lastIndexOf](https://stackoverflow.com/questions/1799543/how-to-catch-everything-before-the-underscore-in-a-filepath-with-javascript/1799586#1799586) is the fastest by a long shot.
```
var end = filename.replace(/.*_/,'');

```