473,836 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex Expression to split on a quote

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(Str ing,"(\"")"), which
gives me an array of strings:

"X:Y\Z.exe
"
"123

I thought that using (\") would be what I needed (escaping a single quote),
but that produces a syntax error.

Can someone tell me the correct syntax for a Regex expression to split on a
quote. Or, if there's a better way to do this, I'm open to suggestions.

TIA,

Lee
Nov 21 '05 #1
5 1778
lgbjr,

This link is from every dotnet newsgroup by a lot of people advices to use
Expresso
http://www.ultrapico.com/Expresso.htm

I hope this helps a little bit?

Cor
Nov 21 '05 #2
Hi

In VB syntax, the "" is the escape character for ".

Here is a module for your reference.
Module Module1
Sub Main()
Dim str As String = "asdfsadf""fasd fasdf""fasdfasd f"
Dim strs() As String = Split(str, """")
For Each s As String In strs
Console.WriteLi ne(s)
Next
End Sub
End Module
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
Peter,

Good catch,

:-)

Cor
Nov 21 '05 #4
Great Tool! Thanks for the link!

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oz******** ******@TK2MSFTN GP09.phx.gbl...
lgbjr,

This link is from every dotnet newsgroup by a lot of people advices to use
Expresso
http://www.ultrapico.com/Expresso.htm

I hope this helps a little bit?

Cor

Nov 21 '05 #5
Lee,
What are you expecting as output?

Reading "within each set of quotes" it sounds like you expect a 2 element
array with:

(0) = "X:Y\Z.exe"
(1) = "123"

I would use a pattern such as "(?<value>. *?)" (including quotes), and use a
loop to find each match.

Something like:

Dim input As String = """X:Y\Z.ex e"" ""123"""
Dim pattern As String = """(?<value>.*? )"""
Static parser As New System.Text.Reg ularExpressions .Regex(pattern,
RegularExpressi ons.RegexOption s.Compiled)

Dim list As New ArrayList

Dim match As match = parser.Match(in put)
Do While match.Success
list.Add(match. Groups("value") .Value)
match = match.NextMatch ()
Loop
Expresso & RegEx Workbench both have wizards of varying degrees to help you
build your expression, plus they allow you to test your expressions, also
the analyzer/interpreter in each is rather handy.

Expresso:
http://www.ultrapico.com/Expresso.htm

RegEx Workbench:
http://www.gotdotnet.com/Community/U...-4ee2729d7322A

tutorial & reference on using regular expressions:
http://www.regular-expressions.info/

The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/de...geElements.asp

Hope this helps
Jay


"lgbjr" <lg***@online.n ospam> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
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(Str ing,"(\"")"),
which gives me an array of strings:

"X:Y\Z.exe
"
"123

I thought that using (\") would be what I needed (escaping a single
quote), but that produces a syntax error.

Can someone tell me the correct syntax for a Regex expression to split on
a quote. Or, if there's a better way to do this, I'm open to suggestions.

TIA,

Lee

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2169
by: Julie | last post by:
I'm an admitted regex moron, but I need help w/ an expression for parsing. Here is the input string: (123.45)ABC(44.55) with a regex expression of \(|\)
6
4805
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....
17
3984
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher http://forta.com/books/0672325667/
7
2263
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not getting the results I expect. Dim SA as string() Dim S as string S="FBE"
4
1929
by: MooMaster | last post by:
I'm trying to develop a little script that does some string manipulation. I have some few hundred strings that currently look like this: cond(a,b,c) and I want them to look like this: cond(c,a,b)
7
2227
by: Jordi Rico | last post by:
Hi, I know I can split a string into an array doing this: Dim s As String()=Regex.Split("One-Two-Three","-") So I would have: s(0)="One" s(1)="Two"
10
1889
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 i.e. 6 comma-delimited pairs of integer numbers separated by the
3
2302
by: ommail | last post by:
Hi I wonder if regular expressions are in general sower than using classes like String and Char when used for validating/parsing text data? I've done some simple test (using IsMatch()) method and the result was that Regex is either as fast or two times slower than method which used methods from classes
7
2233
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
9812
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
10828
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10534
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10579
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
9364
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...
1
7775
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6975
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
5644
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...
2
4004
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.