I am looking for an implementation of fowler's Template View pattern

  • Thread starter Thread starter Julia
  • Start date Start date
J

Julia

Hi,

I need to send HTML messages and embedded properties which set by the user
I would like to use fowler's Template View pattern,does any one implemented
it?

Thanks in advance.
 
Ok i did it,just need help with RegExp
How do i find all matches for

<%PropertyName%> where PropertyName can contains a-zA-Z0-9

Thanks.
 
Hi,

If your properties will have <% - %> symbols and you are interested in the
content. Use Eg1, or if you properties are like words (alphanumeric) use eg2.

Eg1,

Reg Ex = "<%([^<%]*?)%>"
Explanation = Look for starting <% and should have again <% but it should
end with

Input string = <%test <%Width=100%> Satheesh <%Height=100%> test%>

then Output
Width=100
Height=100

Eg 2:
RegEx = "[\w]+";
Input string = <%test <%Width=100%> Satheesh <%Height=100%> test%>
output
test
Width
100
Sathee
Height
100
test

Code in C#.
string input = "<%test <%Width=100%> Satheesh <%Height=100%> test%>";
string s1=@"<%([^<%]*?)%>";//(...)
string s2=@"[\w]+";
Regex r = new Regex(s1);
MatchCollection mc= r.Matches(input);
foreach(Match m in mc)
{
Console.WriteLine(m.Groups[1].Value);
}
r = new Regex(s2);
mc= r.Matches(input);
foreach(Match m in mc)
{
Console.WriteLine(m.Groups[0].Value);
}

Satheesh.
 
Back
Top