Regex - .net Regular Expression To Match Two Words Separated By Comma Not Working?

Mar 4, 2010

I am pretty good with perl regular expressions but evidently I am at a loss on why this doesn't work.The code below stores "Person Test" in output variable.

im output As String
Dim userName As String = "Test, Person"
Dim re As New Regex("(w+),s(w+)", RegexOptions.Singleline)
output = re.Replace(userName, "$2 $1")

So why doesn't the following code store "#Test##Person#" in output variable.

Dim output As String
Dim userName As String = "Test, Person"
Dim re As New Regex("(w+),s(w+)")
For Each Match As Match In re.Matches(userName)
output &= "#" & Match.ToString & "#"
Next

View 2 Replies


ADVERTISEMENT

Regex - Regular Expression To Split By Comma + Ignores Comma Within Double Quotes?

Feb 7, 2012

I'm trying to parse csv file with VB.NET.csv files contains value like 0,"1,2,3",4 which splits in 5 instead of 3. There are many examples with other languages in Stockoverflow but I can't implement it in VB.NET.Here is my code so far but it doesn't work...

Dim t As String() = Regex.Split(str(i), ",(?=([^""]*""[^""]*"")*[^""]*$)")

View 2 Replies

Match Whole Words With Regular Expression For Any Kind Of String?

Jan 4, 2012

I want to match whole words for any kinds of strings, my

Text: to happening behitond .to.the to curtains of this .<NET> open <NET> sou<NET>rce project.<NET>

now i have tried this to find "<NET>" (without quotes) the whole word with[code]...

View 3 Replies

Regex - Extract SubString Based On Regular Expression Match

Apr 26, 2012

Quick RegExp problem (i hope). I need to identify a sub string from any string based on a regular expression. For Example, take the following strings:

[Code]...

View 3 Replies

Regex To Match 4 Groups Of Letters/numbers, Separated By Hyphens?

Jul 14, 2011

I need a regular expression that will match this pattern (case doesn't matter):066B-E77B-CE41-4279

View 4 Replies

Regular Expression - Match A String

Jul 2, 2009

I want to match a string for example "yes" but where it is not in brackets so that the following would be matched: yes (bla yes bla) bla yes

View 7 Replies

Regular Expression - Match Domain In URI

Jan 8, 2011

How can I match the domain part only of a URI with regular expressions? I see lots of examples but the mutch the subdomain too. What I am looking to do is to capture only the domain. So, for example [URL] should match only google. As a secondary question, I am looking to implement this on a VB.NET program. Would there be some other way to do it without regular expressions?

View 2 Replies

Regular Expression : Match A String That Contains A,B,C,D,E And F?

Jul 2, 2009

I want a regular expression for the following issue:I want to match a string that contains A,B,C,D,E and F. string length should be 0 to 6. and not character should be repeat in the string.Example: ABCDEF, ACDEFB, EFBCDA, etc. but not ABBCDES/W Engineer

View 3 Replies

Match A Certain Url From An Html Page Using A Regular Expression?

Sep 14, 2009

I would like to match a certain url from an html page using a regular expression. For example I only want the url that appears after the <h2 header in the html page.basically here is the url I want to match; so what would the regular expression look like.

<h2 style="display: block"><a href="http://url.com/">url</a></h2>

I have matched the href part, but I only need to pull this particular one on the page that appears after the h2 header.

View 14 Replies

.net - Regular Expression To Pull Words Beginning With @?

Mar 5, 2010

Trying to parse an SQL string and pull out the parameters. Ex: "select * from table where [Year] between @Yr1 and @Yr2" I want to pull out "@Yr1" and "@Yr2" I have tried many patterns, but none has worked, such as:

matches = Regex.Matches(sSQL, "@w*")

and

matches = Regex.Matches(sSQL, "@w*")

View 2 Replies

Office Automation :: Find Strings That Match A Regular Expression?

Dec 28, 2009

Is it possible to use regex with Range.Find.Text or set the Word.Range according to a regex in word automation? I just want to find strings that match a regular expression an manipulate them.

View 2 Replies

.NET Regular Expression To Split Multiple Words Or Phrases?

Mar 19, 2010

I'm using the code below to take a string and split it up into an array. It will take: Disney Land and make it two separate elements. If the string contains "Disney Land" then it is one element in the array. Works great, however it adds some empty elements to the array each time. So I just iterate over the elements and remove them if they are empty. Is there a tweak to the code below that will prevent those empty elements from occurring?

Private m_Reg As Regex
m_Reg = New Regex("([^""^s]+)s*|""([^""]+)""s*")
Dim rezsplit = m_Reg.Split(criteria)

View 2 Replies

C# - Regular Expression - How To Find Words And Quoted Phrases

Jun 22, 2010

I am wanting to take a string of say the following:

Guiness Harp "Holy Moses"

So that in C# or VB get a match set of:

Guiness
Harp
Holy Moses

Essentially it splits on the spaces unless there are quotes around the spaces, then those words between quotes are considered a single phrase.

View 4 Replies

Regex :: How To Write Regular Expression

Sep 14, 2010

My coworker needs me to write him a regular expression for his vb.net app.I do not know vb and he does not know regex.The regex he needs is:/.*web id: ?(d+).*/iBasically he needs to search a string for something like "web id: 345" or "web id:2534" and retrieve the ID.He took what I gave him above and was able to put this together:

Dim strPattern As String = ".*web id: ?(d+).*"
Dim strReplacement$ = "$1"
GetWebId$ = Regex.Replace(LCase$(strNote$), strPattern$, strReplacement$)

[code].....

View 2 Replies

Comma Separated Value Find The Value In A Comma Separated String?

Jul 11, 2011

I have a string like

human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp

i need code for find the input string.

View 3 Replies

Regular Expression To Match Alphabetic String And Require At Least One Uppercase And One Lowercase

Jul 20, 2009

I am trying to write a regular expression string match in vb.net. The condition that I am trying to implement is that the string should contain only alphabets and must contain atleast one letter of both lower and upper case. i.e AAA-fail, aaa-fail, aAaA-pass.

The regular expression that I have come up with is ^(([a-z]+[A-Z]+)+|([A-Z]+[a-z]+)+)$

View 3 Replies

Regular Expression To Match Dates In Dd/mm/yy Format And Check For Valid Values

Jun 9, 2010

Does anyone have a regurlar expression available which only accepts dates in the format dd/mm/yy but also has strict checking to make sure that the date is valid, including leap year support?

I am coding in vb.net and am struggling to work this one out.

View 8 Replies

Regex - Match Words Driven From A Database In A String Input

Jun 27, 2012

I am trying to match words driven from a database in a string input using VB .NET
The syntax I am using is so simple:

[Code]...

View 1 Replies

Regex - ASP Regular Expression For UK Telephone Format?

Sep 23, 2009

I want regular expression validator for my telephone field in VB.net. Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext?

View 3 Replies

Regex - Regular Expression With Specific Criteria

Jan 31, 2011

I'm trying to type a regular expression that follows the following format: [URL] There are no special characters or numbers permitted for this criteria. I thought I had it down, but I'm a bit rusty with regular expressions and when I tested mine, it failed all across the boards. So far, my regular is expression is:

[Code]...

View 3 Replies

Building Regex (regular Expression) - Get Data Out Of String?

May 21, 2009

ok, For the moment I have a string() where each element is in the structure of

[Code]...

View 2 Replies

Regex - Capture The Repeating Data Using A Regular Expression In .Net?

Feb 7, 2011

I'm trying to find the right RegEx to capture some (potentially) repeating data. I don't know how many times it will repeat. If I give an exanple of the data and what I want to capture can anyone point me in the right direction? It's the .Net regex engine (Visual Basic)

[Code]...

View 1 Replies

Regex - Parsing Excel Reference With Regular Expression?

Oct 14, 2010

Excel returns a reference of the form

=Sheet1!R14C1R22C71junk

("junk" won't normally be there, but I want to be sure that there's no extraneous text.)I would like to 'split' this into a VB array, where

a(0)="Sheet1"
a(1)="14"
a(2)="1"

[code]....

I'm sure it can be done easily with a regular expression, but I just can't get the hang of it.

View 2 Replies

Regex - Regular Expression That Requires At Least ONE Digits And SIX Maximum

Jan 21, 2011

I need a regular expression that requires at least ONE digits and SIX maximum. I've worked out this, but neither of them seems to work. ^[0-9][0-9]?[0-9]?[0-9]?[0-9]?[0-9]?$ ^[0-999999]$

View 4 Replies

VS 2010 Proper Regular Expression (Regex) Pattern?

Apr 24, 2012

It seems up until now I've never used Regex, nor even heard of it. But once I did I realized how extremely useful this is. Having said, it's been 2 days since I've began looking into constructing my own patterns. My most recent being for decimals. Is the pattern I provided below "proper"? and are there also any improvements I could be making for a more efficient patter, which would minimize any possibility of a loophole? [code] So for my use, this is doing what it's supposed to being doing under every test I can through at it. But do mind the 0. and .0, I have a function to normalize these as they are proper, I just pad the left and right accordingly. I found most regex questions asked here..and yes I am doing this in vb.net so it fits. If not, then feel free to move this post somewhere else better suited for the topic of discussion.

View 12 Replies

Regex - Regular Expression To Check Input On Multiline Textbox?

Mar 15, 2011

regex - regular expression to check input on multiline textbox

View 5 Replies

Regex - Regular Expression To Convert Ul To Textformat And Back, With A Different Attribute Value For First Tag ?

Apr 1, 2010

This is a related to a previous question I have asked here, see the link below for a brief description as to why I am trying to do this.Regular expression from font to span (size and colour) and back (VB.NET).Basically I need a regex replace function (or if this can be done in pure VB then that's fine) to convert all ul tags in a string to textindent tags, with a different attribute value for the first textindent tag.For example:

<ul>
<li>This is some text</li>
<li>This is some more text</li>[code].....

Basically I want the first ul tag to have no indenting, but all nested ul tags to have an indent of 20.

View 2 Replies

Regex - Regular Expression To Parse Whitespace-delimited Data?

Jun 18, 2009

I have written code to pull some data into a data table and do some data re-formatting. I need some help splitting some text into appropriate columns.

CASE 1

I have data formated like this that I need to split into 2 columns.

[Code]...

column is the first 11 characters That is easy.column 2 should contain all the text after the first 11 characters up to but not including the first number.The last column is all the text after column 2

View 4 Replies

Regex Regular Expression To Remove Lines Which Start With Certain Text?

Mar 24, 2012

I know it may be quite easily for you. i have a text which contains 40 lines, I want to remove lines which starts with a constant text. check below data.

When I used (?mn)[+CMGL:].*($) it removes the whole text , when I use (?mn)[+CMGL:].*(
) , it only leaves the first line.
+CMGL: 0,1,,159
07910201956905F0440B910201532762F20008709021225282808
+CMGL: 1,1,,159

[Code]...

View 1 Replies

Regular Expression (RegEx) To Replace Floating-point Numbers In XML?

Aug 22, 2011

I'm using Visual Basic 2010 Express to edit an XML file. I want to replace items that have (typically) non-zero floating point numbers with a single zero.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved