.net - Grabbing All Regex Matches Of "$#" From A String?
Jun 24, 2011
I have a string that contains multiple instances of a dollar sign followed by a positive number. I need to grab each instance out using regex. Here's an example of a string:
"This that $1 who $2" Here's what I have so far using vb.net: Dim wordSplitMatches As Match = Regex.Match("This that $1 who $2", "($d+)+")This works great for grabbing the $1 but how do I set it up so that I get multiple groups with all the matches in?
I've been working on this RegEx for the past day or so and I think I have it worked out so that it returns the data I want. First a little background.I have a content editor that users will be able to edit web pages. They can format text, add links, etc.. standard content editor stuff. When they click save, the editor provides the ability to get the content (editor.Content) and put it into a string. What I want to do is get any links (<a> tags) and find out if they are internal or external links and if they are PDF files.
With this, I am able to separate the domain (if it has one) and the path out. Then, I loop through the matches...
dim matchColl as MatchCollection = Regex.Matches(editorContent, regExString) For Each m as Match in matchColl If m.Groups("domain").value <> myInternalDomain and m.Groups("domain").value <> "" then 'this is an external domain... do some stuff
[code]....
My question is this... the parts where I 'do some stuff' to the values, what would be the best way to get that back into my 'editorContent' string? I could probably put the editorContent into a StringBuilder and do a whole bunch of replaces on it, but is that very efficient?So, for example, with the PDF, I want to specify that it open in a new window (target="_blank") and for the external URL, add some javascript code into the onclick attribute.
i have to search a string for a few words eg, dog, cat, lion but i want regex to fail if lizard is found in the string even if it contains cat, dog or lion.ismatch(pass) "dog|cat|lion" "This is not your average cat!"ismatch (fail) ??? "This is not your average cat! It's a lizard."??? - here the regex statement is unknown word spaces and boundaries or lower/uppercase is not a concern. I run the string through Replace(" ", "").Trim(" ").ToLower before handover to Regex.
Trying to parse this and return the following 3 items: [code] Using this regex expression below I get the matches, but drop the leading "-" at the front of each grouping. I get the "-" in the middle of the group though. [code]
I am working on my application to extract the value from my php page using with the regex pattern. I can extract the value using with the mystrings1 tags with no problem, but I can't be able to extract mystrings1 and mystrings2 tags in the same line.
I'm searching through an html page and I want to put all of the Regex matches into an array? How would I go about doing this? I see the Regex.Matches but I can't quite understand how to use it an MSDN sucks when it comes to explaining it.
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.web.com") Dim response As System.Net.HttpWebResponse = request.GetResponse
CREATE VIEW TestView AS SELECT value1, value2 FROM TABLE_0[code]...........
for each strObjectName in tables, to check whether or not the view depends on this object.But this fails on table_12 (and results in cyclic dependencies) for example, because tables contains "table_1". Aaargh.I need a regex that can check if the view definition contains a function name, table-valued function or another view...
( For checking with System.Text.RegularExpressions.Regex.IsMatch([code].....
But it fails, plus it doesn't account for object names embraced in brackets, like
I got an app, which receives data via a R232 port, convert it to a string and on the other side I got a database, where the strings are saved. How can I find a way to compare the string with all strings in one database column and get back the another stringform the same row in this database. I never programmed a database
Using this regex expression below I get the matches, but drop the leading "-" at the front of each grouping. I get the "-" in the middle of the group though. Here is the expression I currently use.
Dim regex As New System.Text.RegularExpressions.Regex("{0,1}d{1,2}.{0,1}d{0,2}{1}-{0,1}d{1,2}.{0,1}d{0,2}s{1}-{0,1}d{1,2}.{0,1}d{0,2}s{1}-{0,1}d{1,2}.{0,1}d{0,2}, RegexOptions.Singleline)
We have an in home application that does sales order, and displays them on a webpage, in bulks of 50. Currently Right now, I can get the webpage HTML code, however I am not sure how i loop through that, and get the data I need.The HTML that i want to get looks like this
I have an app that contains a DataTable that I must summarize. In that table is a Status column (also the index order) and I want to write a loop in which I compute the count for each status. So I wrote my loop and tried to use the compute function of the Datatable class, but I cannot get it working due to some constraints - specifically this...
[Code]....
You can see what I am doing here is grabbing the string value of the Status column, and then trying to get a count of how many records have that Status. My ultimate goal was to cycle the Table and count each time the status changes. But the error I get has to do with where I store the Status in a String, and then issue the second parameter on the Compute function which contains a variable (sumString) and this is where Compute is crashing - and of course, I can see why - my Status is not literal and thus not in quotes.
Generally speaking, is there any way to manage this kind of thing? In my (very) old FoxPro days one would use a macro such as "Status = &sumString" and VFP would translate sumString to its literal. I have never discovered a way to do that in .NET.
Basically I want to retrieve all possible substring matches with n characters from a string, Here's my initial code but it only returns 2 matches.[code]...
I'm currently grabbing HTML from my site using webrequest and storing it in a string. I'm looking to take this string, and scrape all of the prices in order to calculate this against my cost price (for a consistent profit spreadsheet). What is the most feasible way to do this? Would using a webbrowser control be a better idea?
I'm trying to integrate a parental controls feature on my webbrowser. Now, the user creates a text file containing a list of the words they don't want their child searching. Here's an example of what would happen. The list looks like this (I wont use vulgar words):
dog cat baby fish tree
and the kid tries going to "treeandbabynectar.com". I want a messagebox to come up saying "Site blocked". I want it to be able to detect the tree and baby in treeandbabynectar and realize the text file contains the word tree and baby and block the site. Is this possible? How would I do this?
How to check if string entered in a text box matches a field in a data table
I have a form with two text boxes for users to enter their Username and Password. When they enter their details and click the 'Login' button I want their details to be
checked against data in a data table to see if they match or not. I am using an 'if...else' statement but can't work out the syntax to use. My code is as follows[code]...Check when string entered in a text box matches field in data table?
How to check if string entered in a text box matches a field in a data table.I have a form with two text boxes for users to enter their Username and Password. When they enter their details and click the 'Login' button I want their details to be checked against data in a data table to see if they match or not. I am using an 'if...else' statement but can't work out the syntax to use. My code is as follows:[code]The fields I want to match the textbox strings against in my database table are called 'Username' and 'Password'.
Using VB.NET, Is there a way to do this RegEx call in 1 step... instead of 2-3? I'm trying to find the word "bingo", or whatever is between the START and END words, but then also inside the inner FISH and CAKES words. My final results should be just "bingo".
Dim s1 As String = "START (random string) FISH bingo CAKES (random string) END"
I'm here again asking stupid questions. I don't have really get this but i ask again but i try explain all better. Here is a website link and i want catch string from here. Look page's source code and find first what starts <td> someword </td> I use this code for catch word from page. Visual Basic Express 2008
the string ordering does not matter Z, X, or c can be any order in the string but the regex must fail if all three are not present. I can easily do Three different regex but was wonder can this be done with one expression?
I would like to have a only part of a string... I have a string[URL] and i want only the part thats past the last / so i would actualy get only "file.part4.rar"I know that this can be done through Regex, But I have never used that, and I read the documentation on it, but I do not understand the part of...
Dim rx As New Regex("^-?d+(.d{2})?$")
What dose each of those characters do and how dose it effect the output...