473,700 Members | 2,393 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 6097
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
1860
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
1230
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
1584
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
3604
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
1163
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
2433
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
21037
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
2991
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
1195
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
8645
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
8973
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
8925
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
7810
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
5903
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
4404
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
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3089
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
3
2028
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.