Reputation: 38825
According to this post, I tried to use ^.*(?!http).*$
to find all lines that is not containing the string http
, but no luck.
TEXT:
"NetworkError: 404 Not Found - http://wap-uat01.webuat.opg/finance/img/arrow.gif"
arrow.gif
GET http://wap-uat01.webuat.opg/site/brknews/xml/focus/focus_finance.xml?dummy=1372124875337
404 Not Found
19ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/fin/xml/delay/topten/topStock_stock_up.xml?dummy=1372124875339
404 Not Found
23ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/fin/xml/delay/topten/topStock_stock_down.xml?dummy=1372124875341
404 Not Found
22ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/fin/xml/hotStock/fin_hotstock_utf8.xml?dummy=1372124875342
404 Not Found
27ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/fin/xml/delay/index/u_HSI.xml?dummy=1372124875343
404 Not Found
32ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/fin/xml/delay/index/u_HSCEI.xml?dummy=1372124875345
404 Not Found
32ms
xui-2.0.0.js(1221 line)
GET http://wap-uat01.webuat.opg/site/xml/polling.xml?dummy=1372124875346
Is there any idea for this issue? Thanks.
Live demo: http://regexr.com?35b85
Upvotes: 0
Views: 178
Reputation: 14375
Firstly, to test it in the manner you are seeking, turn on "multiline" mode. The ^
character indicates the beginning of ALL text otherwise. (And without dotall, the .*
sequence won't go past new lines, though with multiline mode on, you do not want dotall.)
I think this expression ought to do what you want, but it is not working on that page (my guess would be because of an issue highlighting newlines):
^(?!.*?http).*$
However, it is working here:
alert(
/^(?!.*?http).*$/gm.exec('abhttpc\nq')
)
And if you don't want empty lines, you can replace the above regex with:
^(?!.*?http).+$
And that DOES show the results you are probably looking for: http://regexr.com?35b8h
The difference between our expressions is that yours allows the expression to find any number of characters which are not followed by "http" and then any number of characters afterward. So, for the line:
"NetworkError: 404 Not Found - http://wap-uat01.webuat.opg/finance/img/arrow.gif"
...your expression
^.*(?!http).*$
...would go as far as it could go without encountering http
immediately afterward, i.e., "NetworkError: 404 Not Found -
(i.e., stopping before the space) and accept that, and then continue with the final http://wap-uat01.webuat.opg/finance/img/arrow.gif"
code (i.e., the code starting with the space), going all the way to the end of the line.
In my modified code, however, it excludes cases where "http" can be found anywhere after the beginning of a line, and then, if it can't, it includes all characters until the end of the line in the results (remembering that the (?!...)
check did not actually consume any characters):
^(?!.*?http).+$
Upvotes: 1