Regex issue with xml file

  • Автор темы Автор темы cool7878
  • Дата начала Дата начала

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
 

Вложения

  • 2.xml
    2.xml
    65,6 KB · Просмотры: 895
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>)
 
Thanks for the answer. But it still did not work. Even with the shortest match option enabled. Any other help?

Raj
 
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...
 
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
You rock man! I have just realized that too. It is just not showing the #.

Thank you so much!

Raj
 

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