0

I have wrote a regular expression in Javascript in an ASP-file.

var re = new RegExp("<h2>Dollarkurs\sAktuell<\/h2><\/div>"+
        "<div[^>?]+><div><table>"+
        "<colgroup><col[^>?]+><col><col[^>?]+><\/colgroup>"+
        "<tbody><tr><td[^>?]+>Kurs<\/td>"+
        "<td[^>?]+>([^\s^<?]+)\s*<span[^>?]+>[^>?]+><\/span>"+
        "<span[^>?]+><\/span>"+
        "<\/td><\/tr><tr>"+
        "<td[^>?]+>Kurszeit<\/td><td[^>?]+>"+
        "^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$\sUhr"+
        "<\/td><\/tr><tr>"+
        "<td[^>?]+>Kursdatum<\/td><td[^>?]+>"+
        "([0-9\.]+)<\/td>", "gmi");

    var mres = re.exec(htmlTxt);

htmlTxt is(a part of webpage www.finanzen.net/devisen/dollarkurs): HTML CODE enter image description here

But the Object mres is null. How to solve this problem? I need the Object mres.

What I need:
mres[0] is 1,0947
mres[1] is 16:00:00
mres[2] is 28.04.2015

THX a lot!

Ying Style
  • 752
  • 2
  • 7
  • 25

1 Answers1

0

@Fede

I have found the problem.

The regex for +0,58% and 16:00:00 Uhr are wrong.

for 16:00:00 Uhr

solution: ^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?\sUhr

for +0,58%

solution: (-)?\d+\,?\d{0,2}%
Ying Style
  • 752
  • 2
  • 7
  • 25