Page 1 of 1

Rex help

Posted: Thu Dec 24, 2015 4:30 am
by josmani
Hi guys,

Would be grateful if you can help me with the following REX expressions.

1. Want to search for the first occurrence of an image tag in a document <img src="some url" alt="possibly some text" />. $ret needs to have the the whole tag.

2. I have a URL structure like "/category/subcategory/docid/sometext.html". I need to get each element (category, subcategory, docid, sometext) in to separate variables.

Many thanks for your usual help.

Rex help

Posted: Thu Dec 24, 2015 8:09 am
by mark
1. <rex ">>=!<img\P*<img=[^>]+>" $data>

2. <split "[/.]" $data>
$ret will be an array of all values. You can extract a single item with
<loop max=1 skip=$n $ret><$varn=$ret></loop>
Where $n is the array index. 0 is the first element.