Tuesday, 20 August 2013

PHP regex to find value of Apache Tile attribute

PHP regex to find value of Apache Tile attribute

I want to use PHP to search a directory of files (views.xml files) and
pull out values from any attributes named "window_title_key".
The attributes look like this:
<put-attribute name="content" value="/WEB-INF/views/login/content.vm"
type="velocity" />
<put-attribute name="window_title_key" value="window_title_login_page"
type="string"/>
For each file, I want to ignore all lines except those that start with
<put-attribute name="window_title_key".
Then, on those lines, I want to extract the value of that attribute. In
this example, the value would be window_title_login_page.
I want the result to be an array of all of the values of all
window_title_key attributes.
What is the regex pattern I should use?
It should be flexible enough to allow for variable whitespace.

No comments:

Post a Comment