473,772 Members | 3,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp.net regex find items in quotes

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
3 2146
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
I didnt find it

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/
"BillGatesF an" <kl******@hotma il.com> escribió en el mensaje
news:11******** *************@f 14g2000cwb.goog legroups.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
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*******@hace b.com> wrote in message
news:ee******** ******@TK2MSFTN GP14.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2085
by: Jon Maz | last post by:
Hi All, Am getting frustrated trying to port the following (pretty simple) function to CSharp. The problem is that I'm lousy at Regular Expressions.... //from http://support.microsoft.com/default.aspx?scid=kb;EN-US;246800 function fxnParseIt() { var sInputString = 'asp and database';
4
728
by: William Stacey [MVP] | last post by:
Would like help with a (I think) a common regex split example. Thanks for your example in advance. Cheers! Source Data Example: one "two three" four Optional, but would also like to ignore pairs of brackets like: "one" <tab> "two three" ( four "five six" ) Want fields like:
9
371
by: Bob Dankert | last post by:
I am trying to create a regular expression to split a string at each newline, unless the newline is within a set of quotes. Unfortunately, I have little experience with Regular Expressions and have been having a hard time creating a pattern to match only newlines not within quotes. Any help would be appreciated with this! Thanks, Bob Dankert
6
4800
by: Dave | last post by:
I'm struggling with something that should be fairly simple. I just don't know the regext syntax very well, unfortunately. I'd like to parse words out of what is basically a boolean search string. It's actually the input string into a Microsoft Index Server search. The string will consist of words, perhaps enclosed in quotes or parentheses. I'd like to use Regex to pull out the words, or the phrases if the words are enclosed in quotes....
5
1774
by: lgbjr | last post by:
Hello All, I have the following type of string: "X:Y\Z.exe" "123" What I need is an array of strings with the information from within each set of quotes. I was trying to use a Regex.Split, but I can't figure out how to escape a quote. The closest I got was Regex.split(String,"(\"")"), which gives me an array of strings: "X:Y\Z.exe
4
3207
by: JS | last post by:
I am writing a C# app that needs to parse a sentence entered by the user for a simple boolean search. I need to capture all of the AND words that are not inside of double quotes. However, I am having a heck of a time figuring out a regex for it. Can anyone assist with a regex to find all the AND's not in double quotes? An example sentence might be: red and blue and "crazy elephant" and "orange and red" and stuff.
8
2591
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: @"@?""""|@?"".*?(?!\\).""|''|'.*?(?!\\).'" I am inputting the entire source file string and using it with RegexOptions.Singleline. This works OK with, unless the string ends with a back-slash. For example: "This is a test\\". Can anybody see how to fix this...
9
2088
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat lot of times here.... Requirement: ------------------- I want to get the value of "href" i.e "city1.html" by searching "city1" between the <a</atag. Please note that "city1" can repeat lot of
7
2230
by: =?Utf-8?B?amFj?= | last post by:
Hi, I have problems with following code and don’t find the bug : // Set ArrayList aArray = new ArrayList(); regStr = new Regex(@"\?)*(\d+)\]"); if(text != null && regStr.IsMatch(text)) {
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.