By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

asp.net regex find items in quotes

P: n/a
hello quite a simple one if you understand regular expressions vbscript and
..net, probably quite hard if you don't

i have a single line input which offers classic search functionality, so if
someone puts something in quotes i.e "A Gibbon" i want to extract that prior
to using the rest of the string

what i need is a regex string that'll turn a postback string eg "A Gibbon"
"A Baboon" "George Bush" doris day into a csv array

("A Gibbon", "A Baboon", "George Bush", "doris", "day")

i can probably handle the doris day after i have got the quoted items

sub btnSearch_clicK()
dim strtext as string = inpSearch.text
dim srchArr as string
so dim myRegEx as new regEX( .....find all items in quotes)

srchArr = myRegEx.Replace( strtext, ...... )

any ideas?

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I believe there was an article similiar to this in the Nov. 2004 Visual
Studio magazine. "Parsing text files using Regular Expressions". And I
said to myself. Who in the world would need to do that! There has to be
an easier way. Now I see that I was wrong. Sorry.

My suggestion is go to the magazine site and search for the article. It
might help

Nov 19 '05 #2

P: n/a
I didnt find it

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/
"BillGatesFan" <kl******@hotmail.com> escribió en el mensaje
news:11*********************@f14g2000cwb.googlegro ups.com...
I believe there was an article similiar to this in the Nov. 2004 Visual
Studio magazine. "Parsing text files using Regular Expressions". And I
said to myself. Who in the world would need to do that! There has to be
an easier way. Now I see that I was wrong. Sorry.

My suggestion is go to the magazine site and search for the article. It
might help

Nov 19 '05 #3

P: n/a
Not being a regex expert myself, the easy hack would be to do it in two
passes.

Pass 1: Get the quoted strings...

use regex... (\".*?\")
means: "get me anything that begins with a quote, maybe contains some
characters, and ends with a quote. no backtracking."
iterate through the groups
append these to your array
then replace all of the quoted strings with a space to avoid re-matching on
pass 2

Pass 2: Get the non-quoted strings...

use regex... ([^\s]+)
means: "get me any sequence of non-whitespace characters."
iterate through the groups
append these to your array
You might also have better success posting this in a regex-specific
newsgroup, or Google "csv regex" which is closely related to what you're
pursuing.

/// M


"Luis Esteban Valencia" <lu*******@haceb.com> wrote in message
news:ee**************@TK2MSFTNGP14.phx.gbl...
hello quite a simple one if you understand regular expressions vbscript and .net, probably quite hard if you don't

i have a single line input which offers classic search functionality, so if someone puts something in quotes i.e "A Gibbon" i want to extract that prior to using the rest of the string

what i need is a regex string that'll turn a postback string eg "A Gibbon"
"A Baboon" "George Bush" doris day into a csv array

("A Gibbon", "A Baboon", "George Bush", "doris", "day")

i can probably handle the doris day after i have got the quoted items

sub btnSearch_clicK()
dim strtext as string = inpSearch.text
dim srchArr as string
so dim myRegEx as new regEX( .....find all items in quotes)

srchArr = myRegEx.Replace( strtext, ...... )

any ideas?

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.