473,806 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex Pattern for VB.Net String?

Is there a regex pattern which will match a VB.Net string? I.E. a regex
which matches ...

"this is a ""vb.net"" string"

(I don't want three matches in this case, I want one.) I've come up with
various solutions for the two-double-quotes-in-a-row problem but none of
them have worked out.

Thanks, Bob
Aug 20 '08 #1
3 6105
On Aug 19, 10:02*pm, "eBob.com" <eBob....@total lybogus.comwrot e:
Is there a regex pattern which will match a VB.Net string? *I.E. a regex
which matches ...

"this is a ""vb.net"" string"

(I don't want three matches in this case, I want one.) *I've come up with
various solutions for the two-double-quotes-in-a-row problem but none of
them have worked out.

Thanks, *Bob
Go grab Expresso and use it's graphical library to work through
creating the Regex. It should get you where you need to be.

http://ultrapico.com/Expresso.htm

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 20 '08 #2
Hi Seth,

Thanks for responding. I am a HUGE fan of Expresso. But in my experience
it has one major flaw - it hasn't made me any smarter! Expresso has helped
me to eliminate all of the dumb ideas I've had so far. But I am not finding
a pattern which is air tight. My latest idea, forgetting for the moment
that almost any character can occur in a string, is ...
"[\w("")]+"
.... and that does match
"some""mo""re"" "
However, it also matches ...
"some""mo"r e"""
.... which of course it should not. I don't understand how it matches the
first case and the second case. In the first case it does seem to be
treating the double double-quotes as a single character, otherwise I'd get
more than one match. But then in the second case it is perfectly happy to
have one double-quote in the string which does not terminate the match.

So despite Expresso I am still looking for a pattern which will match a VB
string.

Bob

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:27******** *************** ***********@x41 g2000hsb.google groups.com...
On Aug 19, 10:02 pm, "eBob.com" <eBob....@total lybogus.comwrot e:
Is there a regex pattern which will match a VB.Net string? I.E. a regex
which matches ...

"this is a ""vb.net"" string"

(I don't want three matches in this case, I want one.) I've come up with
various solutions for the two-double-quotes-in-a-row problem but none of
them have worked out.

Thanks, Bob
Go grab Expresso and use it's graphical library to work through
creating the Regex. It should get you where you need to be.

http://ultrapico.com/Expresso.htm

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 20 '08 #3
On Wed, 20 Aug 2008 12:17:04 -0400, "eBob.com"
<eB******@total lybogus.comwrot e:
>Hi Seth,

Thanks for responding. I am a HUGE fan of Expresso. But in my experience
it has one major flaw - it hasn't made me any smarter! Expresso has helped
me to eliminate all of the dumb ideas I've had so far. But I am not finding
a pattern which is air tight. My latest idea, forgetting for the moment
that almost any character can occur in a string, is ...
"[\w("")]+"
... and that does match
"some""mo""re" ""
However, it also matches ...
"some""mo"re"" "
... which of course it should not. I don't understand how it matches the
first case and the second case. In the first case it does seem to be
treating the double double-quotes as a single character, otherwise I'd get
more than one match. But then in the second case it is perfectly happy to
have one double-quote in the string which does not terminate the match.

So despite Expresso I am still looking for a pattern which will match a VB
string.

Bob
Forget about trying to do this with a single regular expression.
You're not going to have success.

What I suggest you do is split this up into three steps:

1. All VB strings start and end with double quotes, so remove them.
2. With the remaining text, temporarily replace all double quotes
with other characters. So, "some ""more"" text" will become
"some \quotemore\quot e text".
3. Test if the text is now a valid VB string. You can do this with
a simple regular expression like: ^(?!.*").*$
This that expression does not match, it's not a valid string.

You have all text for the string now if the text was a valid string.

You really do not have another choice, since you cannot use balanced
group matching (the beginning " is identical to the ending ", so you
cannot differentiate starting and ending strings unless you replace
all "" characters with something else).
Aug 24 '08 #4

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

Similar topics

2
1865
by: Robert Oschler | last post by:
One of the things that has always thrown me about Javascript regular expression patterns, is that you don't include quotes around them. So how can I modify a regex pattern at runtime. For example, given: var regexPattern = /.*?\s/i; Suppose I want to change the whitespace character to a comma, based on a variable being true or false? // This doesn't work, the string var double-quotes cause the match() method
1
1237
by: Hardy Wang | last post by:
Hi all: I have a big string, format like below: A 8972057019577575 37893 7937 92 702 059032868 -86-248 6408 6048-8608175398 295830 8308 02 B A 3098453-8 3-86-386-860458602862086029 23085308-5-208623-086208620982906 B ......
4
1591
by: Jéjé | last post by:
Hi, I have a file which contain 1 pair of values by line like: Name1=Value1 = I nned to store these pair of values in a sortedlist. So the result expected for the 2 samples lines is: Key Value Name1 Value1
4
3611
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the "LOT:". Source text may contain multiple "SUB: ... LOT:" blocks. For example this is my source text:
0
1168
by: hardieca | last post by:
Hello, I'm creating a regex pattern that will pull out the attribute and value pairs from an HTML tag. What I have so far is: @"\s*(?<attribute>*)\s*=\s*?(?<value>*)" This is all well and good, except if an attribute's value is quoted, the tail quote mark is included when I reference the <value> group. I could remove the apostrophe and quote marks from the pattern, but I
4
2445
by: sherifffruitfly | last post by:
Hi all, I can't see what's wrong with this regex pattern: private int ParsePageViews(string str) { int ret = 0; string pattern = @"Visits.*\n\s*Total\s\.*\s(? <visits>(\d{3})|(\d,\d{3}))";
5
21151
by: vapour | last post by:
Hi, Quick question here, and wondering if anyone can help. I often see the hash character ('#') in regular expressions and am wondering what purpose it is supposed to serve. Example: #(?<=|^) Every bit of online documentation I have looked at states the hash character's purpose is merely to denote the line is a comment. Clearly this is not the case if the regular expression is actually being used to test for something. Can anyone...
2
2995
by: =?Utf-8?B?QWFyb24=?= | last post by:
Hi, I'm having a tricky problem where I want to accept a regular expression pattern from user input but can't get teh escape characters to be prcoessed correctly. If I take the same pattern and declare it in code with a preceeding @ character it works fine. To get the pattern to work from teh suer all \ have to be escaped, e.g. instead of \d a user would have to enter \\d.
2
1200
by: C. | last post by:
Hi, Trying to whip up a Regex pattern that will match the word Directive followed by 4 or more numbers that does NOT end with Home Page. Directive 1234 hello world //Should match Directive 1234 hellow world Home Page //Should not match I tried:
0
9719
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
9598
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,...
0
10623
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
10111
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
9192
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
6877
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
5546
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
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.