开发者

get data using regex

开发者 https://www.devze.com 2023-02-04 20:29 出处:网络
hello i want to get data from a site usingregex http://helwa.maktoob.com/sec8180/art97048/pno1/title_%D8%B7%D8%A8%D9%82-%D9%81%D9%8A%开发者_运维知识库D8%AA%D9%88%D8%AA%D8%B4%D9%8A%D9%86%D9%8A-%D8%A8%D

hello i want to get data from a site using regex http://helwa.maktoob.com/sec8180/art97048/pno1/title_%D8%B7%D8%A8%D9%82-%D9%81%D9%8A%开发者_运维知识库D8%AA%D9%88%D8%AA%D8%B4%D9%8A%D9%86%D9%8A-%D8%A8%D8%A7%D9%84%D8%AE%D8%B6%D8%A7%D8%B1/index.htm

i used that regex /<div class="txtblk"(.*)?<div class="imgv cls">/is

but i gave me Invalid RegExp why ?

i want to get data inside <div class="txtblk"></div>


Try escaping your double-quotes. Depending on your regex interpreter, those might be causing you problems.


The regex itself looks valid.

It depends on where/how you are using it, though; JavaScript for example doesn't know the /s modifier. To simulate a dot-matches-all mode in JavaScript, use [\s\S] instead of ..

Then, you might be running into problems with the quotes depending on the quoting rules for your language.

Also, you probably want to use (.*?) instead of (.*)?. (Or, if it's JavaScript, ([\s\S]*?)).

Finally, using regex to match HTML is not recommended. Use a DOM parser.


u may need to use a site that collects rss from links like this http://www.allwebdesignresources.com/webdesignblogs/graphics/turn-html-web-sites-into-rss-feeds-20-tools-converters-for-html-to-rss-conversions/

0

精彩评论

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