Regular Expressions & Custom Tags
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:
View Replies
ADVERTISEMENT
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:
View Replies
View Related
how to use Regular Expressions in ASP .
View Replies
View Related
Im trying to replace all occurences of a newline with a <br /> tag using regular expressions.
However, I only want to replace the newline with a <br /> tag if the newline does NOT come directly after an </h2> tag.
I cant seem to work out a regular expression to do this. So, for example.
This is an example line. You can see how it would work. would create
This is an example line.<br /><br />You can see how it would work.
and
<h2>The Heading</h2>
This is an example line.
You can see how it would work.
would create
<h2>The Heading</h2>This is an example line.<br /><br />You can see how it would work.
View Replies
View Related
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
View Replies
View Related
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?
View Replies
View Related
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:
View Replies
View Related
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:
.Pattern= "<tr><td><font size='1'>[w]*</font></td><td><font size='1'>[w]*</font></td><td><font size='1'>" & FormatDateTime(now(),vbShortDate)
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?
View Replies
View Related
I am working on an ASP page that parses text using the VBScript.RegExp
regular expression object. My reg expression right now is as follows:
[a-z]+.[a-z]+.[a-z]+/
And if find URL's no problem like: windowsupdate.microsoft.com,
www.cnn.com, etc.
But I need to also find any URL, like these:
www.amazon.com/books/atoz/index.html
OR
msdn.microsoft.com/newsgroups/default.aspx
Some URL with a deeper path than something.something.com if that makes
sense. Any ideas?
View Replies
View Related
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:
.Pattern = "$(.*)"
??
View Replies
View Related
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.
<%
Function Validate_Input(Expression,Pattern)
Dim objRegExp
if Expression <> "" and Pattern <> "" then
Set objRegExp = New RegExp
select case (Pattern)
case "US_PHONE"
' sample matches: 1-(123)-123-1234 / 123 123 1234 / 1-800-ALPHNUM
' sample non-matches: 1.123.123.1234 / (123)-1234-123 / 123-1234
objRegExp.Pattern= "^([0-9]( |-)?)?((?[0-9]{3})?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$"
case "US_DATE"
' sample matches: 02/29/2084 / 01/31/2000 / 11/30/2000
' sample non-matches: 02/29/2083 / 11/31/2000 / 01/32/2000
objRegExp.Pattern= "(((0[13578]|10|12)([-./])(0[1-9]|[12][0-9]|3[01])([-./])(d{4}))|((0[469]|11)([-./])([0][1-9]|[12][0-9]|30)([-./])(d{4}))|((2)([-./])(0[1-9]|1[0-9]|2[0-8])([-./])(d{4}))|((2)(.|-|/)(29)([-./])([02468][048]00))|((2)([-./])(29)([-./])([13579][26]00))|((2)([-./])(29)([-./])([0-9][0-9][0][48]))|((2)([-./])(29)([-./])([0-9][0-9][2468][048]))|((2)([-./])(29)([-./])([0-9][0-9][13579][26])))"
case "EMAIL_ADDRESS"
' sample matches: asmith@mactec.com / foo12@foo.edu / bob.smith@foo.tv
' sample non-matches: joe / @foo.com / a@a
objRegExp.Pattern= "^([a-zA-Z0-9_-.47]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,7}|[0-9]{1,3})(]?)$"
'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])]))$
case "ZIP"
' sample matches: 78754 / 78754-1234 / G3H 6A3
' sample non-matches: 78754-12aA / 7875A / g3h6a3
objRegExp.Pattern= "^(d{5}-d{4}|d{5})$|^([a-zA-Z]d[a-zA-Z] d[a-zA-Z]d)$"
case "CREDIT_CARD"
' sample matches: 6011-1111-1111-1111 / 5423-1111-1111-1111 / 341111111111111
' sample non-matches: 4111-111-111-111 / 3411-1111-1111-111 / Visa
objRegExp.Pattern= "^((4d{3})|(5[1-5]d{2})|(6011))-?d{4}-?d{4}-?d{4}|3[4,7]d{13}$"
case "NAME"
' sample matches: T.F. Johnson / John O'Neil / Mary-Kate Johnson
' sample non-matches: sam_johnson / Joe--Bob Jones / dfjsd0rd
objRegExp.Pattern= "^[a-zA-Z]+(([',.- ][a-zA-Z ])?[a-zA-Z]*)*$"
case "ADDRESS"
' sample matches: 2222 Mock St. / 1 A St. / 555-1212
' sample non-matches: [A Street] / (3 A St.) / {34 C Ave.}
objRegExp.Pattern= "^[a-zA-Z0-9s.-]+$"
case "CURRENCY"
' sample matches: $3,023,123.34 / 9,876,453 / 123456.78
' sample non-matches: 4,33,234.34 / $1.234 / abc
objRegExp.Pattern= "^$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$"
case else
Response.Write("Invalid syntax used to call form validation function.")
Response.End
end select
Validate_Input = objRegExp.Test(Expression)
else
Response.Write("Invalid syntax used to call form validation function.")
Response.End
end if
End Function
' Get data from the form collection and assign to variables
dim str_Customer_Email
dim str_Customer_Phone
dim str_Customer_Name
dim str_Customer_Zip
str_Customer_Email= Request.Form("email")
str_Customer_Phone= Request.Form("phone")
str_Customer_Name= Request.Form("name")
str_Customer_Zip= Request.Form("zip")
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.
View Replies
View Related
I need to strip some text from between two strings, my code looks like this:
SECTION = "My page name"
I need to build a regular expression that will return:
My page name Anyone know how to do this?
View Replies
View Related
i have a table that users are inserting custom tages ,it looks like :
user_id type value
1 99 television
2 98 beach
3 99 coldplay
etc.
now i have to make a search which will show all the users that typed the same value from the same type .i dont want the query to be a textual query (slow ...)what is the right way to do it ?how can i make a query that JOINs to tables from 2 different databases?
View Replies
View Related
I have some asp code in variable so i want to rewrite anchor tags like this:
If i have:
<a href="http://www.sitepoint.com">www.sitepoint.com</a>
To be rewrited as:
<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.
View Replies
View Related
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?
View Replies
View Related
Getting this error:
The name 'squibble' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
/squibble/incFunc.asp, line 13
when trying the following:
Code: ....
View Replies
View Related
I notice that when you have the defualt setup of 404 error
pages the IIS 5.0 log tracks the page the user was trying
to get to and the page they where at when they tryed to
get to the now missing page. I recently wrote my own 404
error page to make it match my site but when I set IIS to
use my custom page it no longer traks the page that the
user was trying to get.
I was told I needed to add some
code to my page to fix this, but I don't know what code to
add. Can someone tell me? (I am useing ASP on the custom
404 error page) I am returning a 404 error response,
everything works fine it is just that IIS does not log
what page the user was trying to get to.
View Replies
View Related
I created my own custom 404 handler and it works, so when I put in
http://www.domain.com/badxxx.html
it produces the correct 404 error and you see
http://www.domain.com/badxxx.html in the url still which is fine.
But when I put in
http://www.domain.com/asdf
it redirects to
http://www.domain.com/index.html
it gives a 302 (moved temporarily) as well as the 404 error.
Why does it do this for not .html files? I dont redirect it at all, and am
using
thestring = Request.ServerVariables("QUERY_STRING") to get the url
but thestring sometimes does not display the asdf depending what I do after
this command, very odd.
does anybody have anyideas as to how to preserve this
http://www.domain.com/asdf in the url and avoid the 302?
View Replies
View Related
I decide to put a custom Hit Counter on my page (below). Then I won't be
reliant on the standard FrontPage one which uses webbots.
It is called by:
<b>Hit Counter: </b><!--#include file="_fpclass/hit_count.inc"-->
The code it includes is below.
OK, it works - sort of.
If I go to Guestbook and then return via the Home button, the counter
increases by 3, not 1.
I can't see why this is happenning.
After returning, a refresh increases it by 2, then another refresh increases
it by 1 ??
I know that many say "Don't use them - it is a sign of an amateur", but I
would at least like to get it working even if I later decide not to use it.
I have thought to make it a conditional include, i.e. if document.referrer
is blank. Is that possible? Code:
View Replies
View Related
how to go about setting up and using custom sessions for user authentication throughout an application?
View Replies
View Related
When you have a custom HTTP 500 error handler, how do you go about making sure all your previously opened recordsets/objects/connections/etc.are closed properly?
It would seem to me that once you hit a 500 error, you have no opportunity to close any of the previously opened objects, eventually causing memory leaks.
View Replies
View Related
I'm developing an application that uses a custom 404 page to deliver all of my site's content. However, doing things this way renders IIS's regular log files pretty much useless.
Are there any established "best practices" for creating your own logging system? I know that others use this technique and I'm hoping someone has some ideas they can pass along. For example, do you log every single page request or do you just log totals per day, week, or month? How do you deal with the increasing volumes of data? Do you collect referrer data, etc.?
View Replies
View Related
I have code for remove button.How to make it a common control so that it will be handy to use.
View Replies
View Related
I asked my hosting service to setup a custom 404 page for me. They did, but when purposely calling a non-existing page with XMLHTTP, the new 404 page returns a 200 / OK status.
They seem to be taking their time trying to fix this, so I wonder if a custom 404 page that truly returns 404 status is a hard thing to set up for individual domains hosted on IIS. I hope my question makes sense to the readers.
View Replies
View Related
im interested in replicating how moonpig.com 's card editor works. in particular how you can display a custom server side font in a wysiwyg editor. i know moonpig uses .net but can this be accomplished using plain ol' asp ?
View Replies
View Related
When a user tries to visit a non-existant page in our web site they receive a custom 404 error message. I want to capture the URL the user tried to visit. Does anyone know where I can find this string?
View Replies
View Related
I am still in the debugging of my website, but I'm nearing the end. As a last phase implementation, I want to be able to catch all asp errors and if there is one, send the user to a custom "sorry bout that" page, rather than having the errors displayed on that; if there aren't any errors, let the page load.
I setup the 404 error, but that doesn't seem to accomplish what I want.
View Replies
View Related
I've created a custom 404 page that performs redirects based on the incoming
URL cross referenced against a database table.
The problem I have is the way IIS sends on the "not found" information.
Example...
http://www.mysite.com/place/missingpage.asp
is sent on to my custom 404 page by IIS via the Querystring as:
404;http://www.mysite.com/place/missingpage.asp
Which is fine,until I add a Quesrystring to the original URL:
http://www.mysite.com/place/missing...var=10&qwert=11
still comes through as
404;http://www.mysite.com/place/missingpage.asp
without the extra Querystring data from the original URL.
Having researched this online it seems many people have this problem and
looks like IIS 6 solves it. However I've also read of people with IIS 6
having the same issue, and of people with IIS 5 that don't have the problem.
(for exmaple: http://www.webmasterworld.com/forum47/1829.htm)
What I'd like to know is if there is definately no way of achieving this
behaviour on IIS 5 without the use of any extra isapi filters. Perhaps a
server configuration option or something...
View Replies
View Related
I would like to generate a custom date format for my ASP output ... i.e.: "5 Apr 06" instead of the "05 April 2006" that the British English 2057 LCID automatically gives me. In other words, I would like a 3 digit month and two digit year.
The code on my page reads as follows now ...
<%= DoDateTime((Recordset1.Fields.Item("StartDate").Value), 1, 2057) %>
View Replies
View Related
I am trying to do the similar to mod rewrite and use the custom 404 rewrite
page to handle the table look up, so www.myweb.com/irish-tapestry-333.html
will redirect to
www.myweb.com?id=333 for the detail pages.
Will google see this forwarding in the 404 redirect page and ignore the
links?Also, how can I make the URL of www.myweb.com/irish-tapestry-333.html
appear in the users url window instead of the www.myweb.com?id=333
View Replies
View Related
We have a requirement where we have to develop a custom Login Page which
will accept user's NT credentials ( Username , password, domain name).
This then needs to be passed to a website which uses Windows Authentication
my question is how do we pass these credentials to IIS in classic ASP?
View Replies
View Related
I have some simple asp code to send a response to the client with aparticular ContentType defined, code shown below:
Response.Clear
Response.ContentType = "application/x-custom"
Response.Write "<?xml version='1.0' encoding='UTF-8'?><testing/>"
Response.Flush
I have a client side ActiveX control implementing IPersistMoniker that isregistered to handle this MIME type. This seems to work fine on some machines and not others. On some of my machines, the control is not instantiated at all. Instead, a blank page is shown in the browser. If I change the ContentType above to something like "text/xml", the response is shown correctly in the browser. This leads me to believe there is a problem with the client mime handler, but it seems to work on most machines.
View Replies
View Related
On windows xp we can modify 500-100.asp file for custom asp error messages. How can we do this on a windows NT 4.0 and IIS.or what is the similar file on NT and IIS?
View Replies
View Related