.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:
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)
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
I'm using a SortedDictonary(Of String, String) in my application, and I experience a strange sorting behavior. Consider the following code example:[code]I would expect the keys to be sorted as "'A", "'B", "'C", "A", "B", "C", which is what you get when comparing the keys "by hand", through the < operator. And yet, iterating through the keys returns "A", "'A", "B", "'B", "C", "'C".How can I change the SortedDictionary behavior to sort the words beginning with ' first?
It has been a while since I have used regular expressions and I'm hoping what I'm trying to do is possible. I have a program that sends automated response regarding a particular file and I'd like to grab the text between two words I know will never change. In this example those words are "regarding" and "sent"
Dim subject As String = "Information regarding John Doe sent." Dim name As String = Regex.IsMatch(subject, "")
So in this case I'd like to be able to get just "John Doe". Every regexp I'm coming up with includes the words "regarding" and "sent". How can I use those words as the boundaries but not include them in the match?
[Code] This Regex "^[" + w + "]+$" finds all words which consists of letters "rca". This matches for all words, because all words are made up from "rca". Is there something I could add, to return False for "caar", because "rca" has only one "a", but "caar" has two "a"?
I'm trying to create a regex which will match either one of the following [code] This regex is supposed to return all and any form of the function that is used.If match string were - FVAL(A,"B")+5 then match group should be FVAL(A,"B")
I can get it to work in VB.NET but not C#. I can't figure out why it works in one but not the other.
[Code]...
As far as I can tell the patterns are identical in both languages with escaping. When I run the VB code I get a match. When I run the C# code I get nothing.
I have just coded the below regular expression. I have a mini rich text editor on a web page (very similar to the one I am using to post this question) and I want to make use of a double asterisk to indicate which words/phrases should be wrapped in a strong tag. The aim is to allow the user to add pre-defined HTML elements without actually having to submit HTML. [code...]
Maybe I am over-optimising this, but I want to know if this can be made more efficient?
It is a little like a search and replace, I want to replace any string that contains any substring in parentheses with the same string but the words in parentheses colored RED: Eg
Take this text in TextBox1:
"The Prime Minister (that idiot from Scotland) made a speech today"
and convert to this text in RichTextBox1:
"The Prime Minister (that idiot from Scotland) made a speech today"
I am trying to use regular expression for extracting data from web page. but everytime i change the URL i need to change my regular expression for URL.
I have the following function that I am using to remove the characters �4 and nulls from my xmlString but I can't find what do I need to change to avoid removing the from my ending tags. This is what I get when I run this function
I have a textbox which takes as input the email address. Do you have regular expression validator in vb.net so that I can check if '@' is present or not in the string
I have a string (can be anything) and somewhere in the middle of the string there's a filename with the extension 'txt'. The filename can basically be anything, and any filename is correct, but with a certain exception.
If the filename ends with .part<number>.txt, the <number> can only be one of the following, 1, 01, 001, 0001.
So I can get the URL value as the only Match from the Regular expression - but I don't understand enough about them (yet) to do this. I have seen RegEx examples that will parse any INI file and get the Name, Value Pairs I just want to get the URL value only from a file no matter what else it contains. My aim is to have something like this:
Dim _pattern As New Text.RegularExpressions.Regex("RegEx") Dim _url As String = _pattern.Match(iniContentString).Value
It seems simple but I cannot seem to create a specific case RegEx where I want everything from "URL=" to the vbCrLf at the End to be my "Match". I have refered to Regular-Expressions.info which has been a help before but still cannot get this simple example to work.
I'm attempting to build a function that will return a regex that is dynamically created.The regex to create will be a range check between two numbers. So far I've got something similar to this (not finished as yet).Is this approach valid, or is there an easier way that I'm overlooking?
Public Shared Function Range(ByVal Minimum As Integer, ByVal Maximum As Integer) As String Return "^([" & Minimum.ToString.PadLeft(2, "0") & "]" & Microsoft.VisualBasic.StrDup(Minimum.ToString.Length, "[0-9]") & "|2[0-4][0-9]|25[0-5])$"
I am trying to validate a csv file of domain names (eg. @google.com, @xyz.co.uk, @xyz.edu etc.) I am using the following Regular Expression: Regex(@"@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}$", RegexOptions.Compiled); Is there scope for improvement on the above?
Regex(@"@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}$", RegexOptions.Compiled); Using the above, I want to pass only values like @gmail.com, @xyz.edu, @co.uk etc... But I find that the values like abc@gmail.com (valid email ids) also pass through.
I am using the below Regular Expression which works fine in case of date validation. But if I select the date from the DatePicket even then it throws alert:Enter valid date. How can I modify the regular expression so as to be compatible with DatePicker.
Set RegularExpressionObject = New RegExp With RegularExpressionObject .Pattern = "^(((0?[1-9]|[12]d|3[01]).-/.-/?d{2}))|((0?[1-9]|[12]d|30).-/.-/?d{2}))|((0?[1-9]|1d|2[0-8])[.-/]0?2.-/?d{2}))|(29[.-/]0?2.-/?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$" .IgnoreCase = True .Global = True End With [Code] .....
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$)
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?
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