Wrox Programmer Forums
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 8th, 2004, 04:32 PM
Registered User
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Regex Help


I need some help with a regular expression. I'm trying to parse, out of text, tags in the following forms:

<%Bar("aasd", "213")%>

I want to get the name of the function/tag in a named group, and pull out the parameters (the text inside the "" for each).

Here is what I have so far for the pattern I pass to the Regex object constructor:


This gets the names correctly ('Foo' and 'Bar'), but the ARGS group on ly contains the following:

    aasd", "213

I understand why I get this, but am at a loss as to how to get what I want. Any help would be appreciated; I'm starting to get a little frustrated. Thanks.

Old October 8th, 2004, 05:33 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


Why is the ? there? The ( is to group the first set of the regexp. Second, in the params part, I see no check for a , or white space.

Old October 8th, 2004, 05:46 PM
Registered User
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the respose.

The '?' is needed to signify a named group; it's necessary, and that part of the expression works fine.

I've since come up with this expression, which works better, but still isn't perfect:


With this, I get the separate parameters, but also the comma delimiters. So if the input was <%Foo("bar", "bar")%>, the captures in the ARGS group would be (without the single quotes):

', '
'' <- empty string

Again, I realize why this is happening, but no matter what change to the expression I try, I only succeed in breaking it completely.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex pendemv JSP Basics 4 December 8th, 2008 08:29 AM
regex mrame XSLT 12 July 25th, 2008 09:37 AM
Regex htran XSLT 2 May 18th, 2005 09:21 AM
More regex help Snib Pro PHP 4 December 16th, 2004 09:56 PM
Need RegEx help Snib Pro PHP 6 November 16th, 2004 06:59 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.