开发者

Help with Regex on Parameter delimiter

I have to match the following text:

var html = '<td align="right" width="26%">


            <span class="text2-mbna" style="position:relative; left:10px;"> 
            $0.开发者_运维问答00</span>

    </td>'

I have this regex

/<span class="text2-mbna" style="position:relative; left:10px;">(?:\s+)((?:\$)((\d|,)+)\.(\d+))<\/span>/.exec(html)

I can actually just replace it in javascript, but I want to know how to NOT capture the dollar($) sign.


Just move (?:\$) before the open paren to its left, giving:

/<span class="text2-mbna" style="position:relative; left:10px;">(?:\s+)(?:\$)(((\d|,)+)\.(\d+))<\/span>/

You don't need (?:) there anyway; it can just be

/<span class="text2-mbna" style="position:relative; left:10px;">\s+\$(((\d|,)+)\.(\d+))<\/span>/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜