<textarea name="whatever">Here is some text area text</textarea>
I know the following pattern works:
<(select|textarea).*(.|
)*?</(select|textarea)>
But the problem is my web hosting company is using ASP scripting engine 5.1 which does not support the non greedy delimiter (?). I doubt they are going to upgrade to 5.5 anytime soon.
I'll appreciate it if anyone can give me a pattern that does the same job but does not use the ? delimiter. Is there a way I can tweak the pattern above so that it works in ASP scripting engine 5.1?
Can anyone give me a regular expression for finding a URL in a string of text?
Essentially what I want to do is find URLs in a text string and embed them in {a href...} tags. However, I haven't used regular expressions all that much in ASP/VBSCRIPT.
I need to create a regular expression for a date field that works only in the following format MM/DD/YYYY with the / in the format. No other format can be inputted into the field. I need 2 numbers for MM 2 Numbers for DD and 4 numbers for YYYY. If the users enter 1 number for month, 1 for day he should get an alert.
I have this code and thought it was working but it is not.
I'm going down the road of learing the pattern matching in regular expressions, and I'm trying to convert the characters into English in my head so I can see whats happening...
For clarity with this one...
[b]([^]]+)[/b]
Ok - the first thing I did was break it up - because it looks a nightmare like that...so now I have..3 parts..
[b]
([^]]+)
[/b]
In part 1 I under stand that the is telling the expression that a special character is coming next, thus escaping the [ and ] respectively, thus , and in part 3 I understand the same and also the escaping of the /, thus - no problems so far...
In part 2 I'm assuming that the brackets are seperating a "pattern" so that I might reference it as $1 later on, I understand that the [^] are saying "not enclosed" so therefore it's going to ignore a ], the + sign however perplexes me - my VBScript book says "Matches the preceeding character one or more times" - so does that mean the ] just before it, or does it mean the character OR characters defined within the [ ] etc?
I'm trying to find a regular expression function to strip contents out of a string which lie between square brackets [].I've got one for chevrons (to remove HTML - as below), but would prefer not to have to replace the chevrons for square brackets first.Code:
function funRemoveHTML( strText ) Dim RegEx Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>" RegEx.Global = True
funRemoveHTML = RegEx.Replace(strText, "") end function how I can modify this for square brackets as opposed to chevrons?
I'm making url's out of text starting with "www" etc. but I've got two problems. Firstly, if the string begins with www it doesn't get matched, and secondly, if there's a dot or a comma directly after the url, it becomes part of the url. I hope someone who is better at this than me will be able to help me out. Code:
reg.Pattern = "(s)(www)(S)(S+)" s = reg.Replace(s, "$1<a href=""http://$2$3$4"" target=""_blank"">$2$3$4</a>")
I'm trying to return a sub string using the regular expression object. I've not really used the regular expression object before and I'm finding it a bit clunky to use.
Basically I'm trying to match the 'description' within the string 'file_description_1'
However I'm unsure how to return the partial, would I use the Execute or Replace methods?
Regex looks like this:
With RegularExpressionObject .Pattern = "file_(.*?)_[0-9]" .IgnoreCase = False .Global = True End With
I've discovered an insidious bug with the VBScript Regular Expression object.I set the pattern to consist of the set of invalid filename characters plus comma. I set global property to true then do a replace on a SID. The Replace does nothing. However, if I attach the C++ (dev studio 2003) debugger to the IIS host process (dllhost.exe), every time I call RegExp.Replace, the stack for one of the process's threads gets scrambled. It ends up with the value 0x00000001 at the top of the stack! If your debugger is set to stop on access violations, it always catches one (invalid read trying to delete). The problem is insidious because, without the debugger running, you would never know this is happening. ASP returns no error. Potentially this could wreak havoc on your web application and cause bizarre failures later on. Has anyone else run into this one? It seems to happen only with the Replace method.
I'm trying to work out a reg.exp. that will pick out a sql statement against a certain set of tables - in this case any table named "Survey~something~", but I only want to pull back those statements where the CompanyID column doesn't appear in the query. (The expression is being used in my editor so it might appear a little strange, but by and large it works the same as you'd expect.)
I have a search results page that lists a series of records with clickable links to view the records. When you click on the link to the record, the record id, the search terms used, and the search type (exactphrase or anywords) is sent through the query string.
On the record page I have been trying to find a regular expression that would find and replace the search terms with < strong >< /strong > to highlight them. I am struggling.
Does any use a similar regular expression. One that, if flagged, will replace an exact string (phrase) or loop through an array replacing any of the words in the string?
I'm trying to write a function to return submatches. I want to do this because I want to run a match on matches of matches of yet other matches, so it seemed to me it would be easier to work with if there was one line of code that would return a collection or array of matches. Here's what I got:
<% Dim objRegExp Set objRegExp = New RegExp Dim objMatches, objMatch
Set submatches = getsubmatches("this should hopefully match and print eight words", "(w)", TRUE, TRUE)
For i = 0 To submatches.Count - 1 response.write "<br>" & submatches(i) Next
Function getsubmatches(strText, pattern, isGlobal, ignoreCase) Dim data
I'm back with something that makes no sense to me .... as far as I can see the three if statements are identical except for the input. One is the regular phone, then cell phone and then the fax .....
I need help with a regular expression. Here are the rules I need to apply:
Exactly 8 characters Alphanumeric only (no punctuation at all) Must have only one numeric (1 is not allowed) Must start and end with an alpha
I'm doing the length check with a len, so it's not a big deal if it's added in there or not. I have most of it working, but the one that's biting me in the backside is the one numeric check. I thought it would be a simple matter of using: Regex.Pattern = "^[A-Za-z]+d+[A-Za-z]$". However if I use this, I get: ...
Been pounding on this for an hour and eating up my day's productivity, so I thought I'd throw a question out there. (I'm also reading through the Google archives to try to find this answer...)
Windows 2000 Small Business Server
Using regular expressions for the first time, and having difficulty with the replace method. We're searching through a list of vehicle models, trying to replace what we get from the client data with correctly propercased text...ie..we get FORD F150 and replace it with Ford F150; CHEVROLET ES 300 and replace it with Chrevrolet ES 300; ACURA MDX >> Acura MDX. The usual propercase algorithms don't work because of the multiple capitals in some of the model names: we don't want Acura Mdx.
The test method always works. The problem we're having is that, under certain circumstances, the replace method is replacing too much. We've created a table of capitals as they relate to models: ES; MDX; XL; SL; and so on. The pattern we're using is this: ....
I am new to reg expressions and would like to write a regex for a .html page I am working. I want the regex to find every http link (<a href= ) that contains .org. Once it finds every link that contains .org I want to then remove ( exit.asp?url= ) that precedes it as well as add the attribute ( target="_blank" ) to the (<a href=) tag.
This basically will find all instances where I am calling my .asp page that lets the user know they are exiting the main site for an outside source and eliminate this page as long as the link they are clicking is within the original site. Otherwise I call my exit.asp page which notifies the user they are leaving.
Example:
Look for this type of tag (one where the link contains .org): <a href="exit.asp?url=http://myorgwebsite.org/myorg"> Link 1</a>
Replace with this (removes the "exit.asp?url=", but adds target="_blank" attribute): <a href="http://myorgwebsite.org/myorg" target="_blank"> Link 1</a>
I need an asp command to strip out from a string all extra punctuation such as apostrophe, comma, period, spaces dashes, etc etc and just leave the letters.
I want to search a string of HTML and insert a querystring into any url where the url is an asp page and is either a local link /folder/page.asp or of a specific domain http://www.somedomain.com/folder/page.asp. It needs to be able to handle plain links and those with querystrings already in there.
I could do it with instr functions etc but I thought this might a good time to brush up on regular expressions. Can anyone point me in the right dirction?
<a href="http://www.sitepoint.com" target="_blank">www.sitepoint.com</a> out The problem is that urls from my domain shouldn't be changed for example if href="/some_path" or href="http://www.mysite.com/some_path"
I try making some expressions with RegexBuddy but it didnt worked very nice.