regex match() works in FF/Chrome but not IE 8

前端 未结 3 1709
自闭症患者
自闭症患者 2021-01-21 11:43

I have the following jQuery call, which returns a match in FF/Chrome, but returns null in IE 8.

Here\'s the fiddle if you\'d like to try it for yourself.

And her

3条回答
  •  孤独总比滥情好
    2021-01-21 12:36

    Your code would only replace the first occurence of  . However, since you're getting the text using .text(), the replace function should not be needed.

    var m = t.replace(/ /g, ' ').match(/\d+-(\d+)\sof\s(\d+)/);
    

    If your issue is not solved using the previous line, use alert(t) to check whether the input is as expected.

提交回复
热议问题