Can I use regexps in fso.DeleteFile? I've found I can use a '?' and probably a '*' (although that seems a tad brutal) but I'm having trouble with expressions like ([a-z]|[0-9]-).
Am I wasting my time trying to get it to work (i.e. does it support them?) If so, how do I use them? Does it have its own quirky syntax or "standard" regexp? Every example I've found so far just mentions deleting something simple like *.txt.
For the record, I need to "tidy up" a directory full of images by deleting files whose names _don't_ contain particular text. It's quite convoluted and would be far easier if I could just go through each file one by one but hey. Here are the details:
1) I have a list of IDs in an array that I've read from a data source. This is the "current ID" list
2) I have a list of image filenames from a directory in another array. The image filenames contain an ID in them. There could be none, one or more images containing the same ID.
3) I look at each file in turn, extract the ID portion and add it to an array of "found" IDs - crucially, this array is only updated if the ID has not been seen before in another filename
4) I then step through this array and use Filter() to see if the ID is in the "current ID" list somewhere
5) If it is missing from the list, that ID is deemed "out of date" and all associated images containing that ID need to be deleted. Message to screen saying that ID has been deleted.
6) If it is in the list, just print a message saying it is "current" and move on.
I realise I could just step through each file and test it against the current ID list but then the output on-screen would be file-by-file and not ID-by-ID. The client doesn't care how many files there are; they don't even care about the underlying structure - they just point the browser to my script and it deletes the files, shows them which IDs have been removed and tells them how many IDs in total have been deleted.
If I went down that route I would have to keep a record of which IDs I've deleted and output the lot at the end instead of 1 by 1 as I go, which leaves the browser hanging for a while and doesn't give the client reassuring feedback as it ploughs through the directory adding the results to the screen row by row. Code:
I want to get the Structure within the 2 HTML Tags. I am not able to Get the regular expression for it. So here is the Code and could anyone give m ethe regular expression to get the HTML tags between the Code:
I have been trying to run the example listed on MSDN to test a regular expression. I'm running a win2k3 web server edition, WSH is version5.6. I am getting an error everytime I run
Set RegEx = New RegExp
I have seen a few problems on MSDN with users not getting the right permissions for some dll's so I went through the procedures trying to correct that. I've seen the RegExp values in the registry. Even had a friend of mine try the script on his machine. (mind you this comes directly from MS) I cannot get New RegExp to work at all
I've got a page of text which I am assigning to a string. Within this page there are special tags e.g. lots of text....<ti>dogs</ti>..lots more text....<ti>this is a cat</ti> etc.. So I've got a long string interspersed with these tags. Now what I need to do is get a list of the words/phrases that are within these tags. So in my list I would get dogs, this is a cat etc..
I've tried a combination of mid, instr and replace and got it sort of working but there's got to be a more efficient way of doing it. Possibly using regular expressions?
Problem: I want to check the data from a RecordSet.GetString result for today's date. If today's date exists in the row then I want to replace the preceeding <tr> tag with a <tr style='background:grey'>. I made the following objRegExp.Pattern:
This successfully identifies the row as containing today's date. Yea! Now, the replace part.
text = objRegExp.Replace(text,"<tr style='background:grey'><td><font size='1'></font></td><td><font size='1'></font></td><td><font size='1'>" & FormatDateTime(now(),vbShortDate))
This piece works except I lose the data that was actually contained in each cell. How can I have it so that the only thing that gets replaced is the table row tag?
What regular expression would I use to take out all of the money (US amounts) from a string?
Right now I have:
Code: Set RegularExpressionObject = New RegExp With RegularExpressionObject .Pattern = "$(.*)" .IgnoreCase = True .Global = True End With xmlText = RegularExpressionObject.Replace(xmlText,"")
Set RegularExpressionObject = Nothing
which obeously doesn't work. What should I use for:
I have created a template system, and someone pointed a script out that would let me create simple links by using [link]home|http://www.sitepoint.com[/link] which would convert anything between those custom tags into a link, with home being the text displayed and the web address the location.
Now I need a way to be able to edit the script, well the RE Pattern so I can use it for other things. Code:
I have a problem. Of course, or I wouldn't be posting here. Ok, now that Mr. Obvious is out of the way ...
I'm looking for some ideas. Take a look at the code below. I'm looking for the most efficient way to validate form field input on the server-side. I'll provide what I have. What I'm looking for are improvements.
'The next line is supposed to be an RFC 2822 address compliant validation expression 'objRegExp.Pattern= "^(?:[w!#$\%&'*+-/=?^`{|}~]+.)*[w!#$\%&'*+-/=?^`{|}~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-](?!.)){0,61}[a-zA-Z0-9]?.)+[a-zA-Z0-9](?:[a-zA-Z0-9-](?!$)){0,61}[a-zA-Z0-9]?)|(?:[(?:(?:[01]?d{1,2}|2[0-4]d|25[0-5]).){3}(?:[01]?d{1,2}|2[0-4]d|25[0-5])]))$
if not (Validate_Input(str_Customer_Email,"EMAIL_ADDRESS")) then response.write ("error") if not (Validate_Input(str_Customer_Phone,"US_PHONE")) then response.write ("error") if not (Validate_Input(str_Customer_Name,"NAME")) then response.write ("error") if not (Validate_Input(str_Customer_Zip,"ZIP")) then response.write ("error")
response.end %>
Now, I'll obviously want to do more than write "error" to the screen with the validated input. What I *really* want ideas on is a more efficient way to validate the fields. In this small example doing them as one-offs isn't bad. On a form that has 20-30 fields it becomes cumbersome.
I want to delete a photo when a user update his profile with a ne photo. It takes from the database the file name of the old photo, put in a session("oldPhoto") and update the database with the new one. Then to delete the old foto I've written the following code that is not working:
I'm entirely new to using FSO's in ASP and I'm hoping someone can help me with a code sample or something to understand how to implement the DeleteFile method. I'm just trying to write a quick script that deletes the file "<%=Path%>"; where "Path" includes the full path and filename to delete.
I can successfully delete files using fso.DeleteFile when in an ASP script. But in Session_OnEnd, where I'd *really* like to clean up files, it appears that DeleteFile doesn't work. I've tried every combination I could think of. I've verified the filespecs I'm using by logging to a session log file.
BTW, I found out the hard way that I can't reference Request.ServerVariables("APPL_PHYSICAL_PATH") from within Session_OnEnd. I had to copy that to Session("AppPath") to keep it around for the OnEnd event. Without that, ASP just bails out of OnEnd, ignoring the remainder of the subroutine.
I'm trying to add a search facility to a page that looks for matches in one, other or both memo fields of a database. The code below works fine if the visitor types in one word, or the term just happens to exist in one of the queried fields.
What I'd really like is for a visitor to type in an expression, or query in the same format as you would use in a search engine and it would find appropriate matches. Any ideas how I can modify the code below to do this?
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.
note that, i want to capture the url that comes after value=". if the value=" comes in the second place in the html tag it works. but if it comes in the 3rd position, then it doesn't work.
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