Extract string from string using Regex
Posted
by stacker
on Stack Overflow
See other posts from Stack Overflow
or by stacker
Published on 2010-05-04T17:17:06Z
Indexed on
2010/05/04
17:18 UTC
Read the original article
Hit count: 407
I want to extract MasterPage
value directive from a view page. I want the fastest way to do that, taking into account a very big aspx
pages, and a very small ones.
I think the best way is to do that with two stages:
- Extract the page directive section from the view (using Regex):
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
- Then, extract the value inside
MasterPageFile
attribute.
The result needs to be: ~/Views/Shared/Site.Master
.
Can I have help from someone to implement this? I badly want to use only regex, but I don't Regex expert.
Another thing, Do you think that Regex is the fastest way to do this?
© Stack Overflow or respective owner