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 April 10th, 2004, 04:34 PM
Authorized User
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default String.Split

Heyah Folks-

I am putting together a search engine for a project.

I have been chopping up keywords using String.Split, but realize it would be so much cooler if it wouldn't split words surrounded by quotes...for use in searches like this:

-"Radiohead Concert" Baltimore-

...and only patterns matching "Radiohead concert" would be used as criteria....

I have a feeling I am not going to have any luck with String.Split...are there teqniques for this anyone could share?



Old April 10th, 2004, 05:21 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

You are going to want to try regular expressions for this. Look into the System.Text.RegularExpressions namespace.
Old April 10th, 2004, 05:53 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Alternatively, you can split on the double quotes first. This way, you end up with an array of "quoted searchstrings", which you can split individually as separate search entries.

I agree with Peter that regular expressions would be much more useful, but they can also be more difficult to learn at first.



Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Innocence by The Smashing Pumpkins (Track 7 from the album: Machina II: Friends and Enemies of Modern Music)

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to split string krevathi1912 Access VBA 10 September 6th, 2007 02:21 AM
string split vidhya XSLT 1 August 10th, 2005 04:53 AM
How to split a string lily611 General .NET 5 March 18th, 2005 01:16 PM
string split by : crmpicco Classic ASP Basics 3 February 10th, 2005 07:49 AM

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