Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 10th, 2008, 12:51 AM
Authorized User
 
Join Date: Nov 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sanjivbshinde
Default Find Matching pattern in Given String

Hello Friends,

     I want to find words between given pattern i.e
suppose my string is like

"Client Name:$$C-Name$$ Date:$$C_date$$ Remark:good"

as $$C-Name$$ and $$C_date$$ are variables

but in whole string i want to find which are the words are between $$(any variable)$$

my output should be like C-Name,C_date may be this is in array.



 
Old October 10th, 2008, 02:49 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

What language are you using? C#? VB.NET?

You could do this with a regular expression and then get the "matches" collection.

Or you could just do it by splitting the string on "$$" and then choosing every other element of the resulting array.
 
Old October 10th, 2008, 02:51 AM
Authorized User
 
Join Date: Nov 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sanjivbshinde
Default

Hi Old Pedant
I want it by using C#

 
Old October 10th, 2008, 06:32 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmm. If you are working with a relatively small string you could do something like:

string SomeString = "Client Name:$$C-Name$$ Date:$$C_date$$ Remark:good";
string[] VariableArray = SomeString.Split("$$");

foreach(string s in VariableArray)
{
     Response.Write(s);
}

If you are working with a large string you may net a bit of performance by creating a RegEx.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pattern Matching for Sequentinal numbers like 1234 sriram_r15 Beginning PHP 3 January 20th, 2005 05:46 PM
javascript pattern matching... rbd Javascript 1 October 7th, 2004 12:20 PM
Question on Pattern matching using VBscript Dereksam VBScript 1 September 9th, 2004 04:45 AM
PHP Pattern Matching joanncae BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 17th, 2004 04:52 PM
Pattern Matching using PHP spraveens PHP Databases 2 March 23rd, 2004 10:03 PM





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