Regex issue with xml file

cool7878

Client
Регистрация
22.02.2013
Сообщения
28
Благодарностей
1
Баллы
3
Hi

I am trying to regex the attached xml file and put all the occurrences of text between <content:encoded><![CDATA[ and ]]></content:encoded> in a list so that I can process it later. I am using the regex code (?<=<content:encoded><!\[CDATA\[)[\w\W]*(?=]]></content:encoded>). But somehow it is not considering ]]></content:encoded> and generating one occurrence only.

Please let me know what I am doing wrong. the file is attached here.

Thanks
Raj
 

Вложения

  • 65,6 КБ Просмотры: 763

peterparker

Client
Регистрация
30.05.2013
Сообщения
20
Благодарностей
0
Баллы
0
Hi Raj,

as far as I can see you did not activate the "shortest match" option. That could be the reason why only one string is generated.

Try it with a question mark in the middle of the code: (?<=<content:encoded><!\[CDATA\[)[\w\W]*?(?=]]></content:encoded>)
 

cool7878

Client
Регистрация
22.02.2013
Сообщения
28
Благодарностей
1
Баллы
3
Thanks for the answer. But it still did not work. Even with the shortest match option enabled. Any other help?

Raj
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
regex is working fine, but what can happen sometimes is issue with direct grab&regex content... try just grabing content and put it to variable, and than try regexing it...
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Raj, are you sure you are looking at the results right? I know it looks like one big mess there, but in my regex builder with the regex....
(?<=<content:encoded><!\[CDATA\[<h3>)[\w\W]*?(?=]]></content:encoded>) I see 11 matches. 11 different results. Even though you don't see the match #'s in there you do have separate results.

And who invited that crazy person above me back in. :p
 
  • Спасибо
Реакции: cool7878

cool7878

Client
Регистрация
22.02.2013
Сообщения
28
Благодарностей
1
Баллы
3
You rock man! I have just realized that too. It is just not showing the #.

Thank you so much!

Raj
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)