I have a bit of code that replaces all links in my forums with hyperlinks. I'd like to add [url=www.sitehere.com]Link[/url] BB Code links to my forums. This is difficult to word, but how do you specify for RegExp to skip links if they are in [url] tags.
I have some code working with Regular Expressions and it works right on my server (W2K Server), but doesn't work on all IIS 5 servers. I originally thought that the servers just didn't have the RegExp object, but a testing script shows that the problem is in the replace statement. Code:
I am requesting a form field which has a UK postcode value eg yo17 9hs, or NE15 7YY. What I need to do is pull out just the first part of the postcode, in this case it will be yo17 and ne15. Anyone help me do this in asp?
strURL = "url that is required" strFileName = sXML
Set oOriginalPO = CreateObject("MSXML2.DOMDocument") Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oOriginalPO.async = False oOriginalPO.load strFileName 'name of file containing cXML data
oXMLHTTP.open "POST", strURL, False 'strURL is our URL you post to oXMLHTTP.send oOriginalPO
So on the assumption that the sXML variable has correct information inside it to send out, can anybody see why perhaps this code isn't working properly?
I have a bit of a problem with UK Post code strings, as you guys in the UK will know, our postcodes are alpha numeric.
LL12 4RS, C4 4GF, DG1 7HD etc etc...
What I need to do is grab the first letter(s) of the post code, ignoring the rest of it. Now, 'cos it can be either 1 or 2 (and in some weird cases 3) letters, I can't do a simple left() on it.I'm guessing something like a regexp will be the way to go? (but I'm a bit hazy on the reg exp thing)
I'm trying to work out how to do a post code search with longitiude and latitude, the idea is to be able to input yuor postcode and the search will return all company stores in that area.
why the following code incorrectly returns 2 as matches count whereas when I change str = "179,80,179,80,179" I get the correct count which is 3? str = "179,179,179" num = 179
Set regEx = New RegExp regEx.Global = true regEx.IgnoreCase = True regEx.Pattern = "(^|,)" & num & "($|,)"
Set colMatches = regEx.Execute(str) response.write colMatches.Count & "<BR>"
I have a string which is an html document - I want to eliminate all the <script>blah blah</script> tags. I can't seem to get the regexp pattern right. Here's where I've got to:Code:
Set oReg = New RegExp oReg.IgnoreCase = True oReg.Pattern = "(<script[. ]*</script>)"
Set oMatches = oReg.Execute(sHTML)
For Each oMatch In oMatches sHTML = Replace(sHTML, oMatch.Value, "") Next
I am trying to write an asp(vbscript) parser for wiki-style pseudo code, and can't get my head round regexp.
I am hoping if somebody could give me an example to work on for one, I could sort the others.
e.g. how do you turn (from within a large string, with varying occurences) .......[image:/mydir/pics/my portrait.jpg | A picture of me]...... into ......<img src="/mydir/pics/my%20portrait.jpg " alt="A picture of me">.....
I'm struggling trying to get the concepts of the regExp function down....
What i'm trying to achieve is to remove all white space from html formatted source code.
I have the following regExp search string to remove all html source code but that is not what i require.. RegExp.Pattern = "<.*?>"
I want to store all html source code and its text/image contents into a DB.
For that reason i want to remove all line breaks and spacing/tabs within the source code so as to only have one exteremely long single line leaving the formatting of the contents of the html code alone all so that i can stuff into a varchar(MAX) field.
what is the syntax for parenthesis? but i don't want to allow <> or / like S would (if i understand that correctly). would i use ascii then, as in: x40 and x41?
Premise: Inserting data into a database form a <textarea> and displaying this data through an HTML page.
When inserting data into a database via a text area and then displaying this data any carriage return that was entered into the database was lost. I Created a function to replace a carriage return with a <BR>. I call this function when I display this data.
If I enter text inside <> into a database and then display this data, any text that was within the <> is lost because it is considered an HTML tag. How can I search the string for the brackets and actually diplay them? I do not want to use Server.HTMLEncode before I insert the data into the database. This is because we often query the database from outside a web browser.
Here is my function I have for the carriage return. I need to figure out how to accomplish this for both < and >. I am sure this is simple but I do not know what the .pattern should be (for a carriage return it is " ".
SET regQuote = New RegExp regQuote.pattern = " " regQuote.global = True catchCR = regQuote.Replace(strText, "<br>")
I'm not so familiar with ASP, so don't shoot me if this one's easy. I have to redesign the front of a Belgian hosting company. On that front they have a domain check like this:
Input field (domain without extension) Hidden fields with populair basic extensions
(<input type=hidden name=ext value=be> <input type=hidden name=ext value=com> ...) Submit button What I want now when the the user submits this form is that IF he adds an extension in the first field (which is not required), the script also checks if that extension is available. Code:
I just realized that it's so important to validate each string, I mean 'each' before you insert data from asp page into database.
I guess some customers just copy data from some electronic document and paste intoform field which it will probably mess up the program.
for example, we have a customer who wants to enter AH12345 into one of our fields, it appears Ğ?Ğ?12345 in hidden field of our asp page, but it displayed AH12345 to the customer, but our program failed because of the data does fit into char field in sql database.
I don't know in reality, how other companies deal with those kind of thing. Do I have write our own regExp to validate each string, since we do need to allow apostrophe or "-" in first name or last name.
is it possible (i heard u can replace) to filter out bad words using regexp? I'm using Replace() but it sucks without ALOT of extra code... but using regexp it seems better, with ignorecase, etc.
I need to truncate a news article to only show a certain number of characters on the front page. the news articles often contain html and the characters in the html are being counted. So, even though I want the text to be truncated at, say, 350 characters, the final result on the page looks like it's been truncated way further up, because the text of the html added to the character count.
here's the code i'm using to truncate
URLFunction ChopLastWord( Line, Length ) If Len(Line) < Length Then ChopLastWord = Line Exit Function End If Dim spaceat spaceat = InStrRev( Line, " ", Length ) If spaceat < Length-20 Then spaceat = Length ' value of 20 is arbitrary ChopLastWord = Left( Line, spaceat ) & "..." End Function
2) when highlighting words (in a search results page for example), I want to match the word ignoring case. however, when wrapping the word in highlighting code and replacing the substring, I want to keep the original capitalization.
for example, if the word to match is marvelous, but the word is stored uppercase in the db, the above code will replace the word with a lowercase version. how do I get around this?
3) I want to remove any and|or that are not inside double quotes in a string. for example,
test = """The dog and the cat""" & " and fox or mouse " & """the cat and the dog"""
resulting in "The dog and the cat" and fox or mouse "the cat and the dog"
I would like to remove only the AND OR linking fox and mouse in the middle of the string. how would I do that?
set typ = server.createobject("Scriptlet.TypeLib")
to create a random string of 36 characters. However, is there a way to create a random string of digits in the length I request? Perhaps a string of 20 digits with a few asterisks thrown in for ease of typing?
Is there a way to 'force' a submit on a form with out actually allowing the user to press a button ? For example...
step1: A from is filled out by a user, then they click the submit button.
step2: The form is 'post'ed to an ASP page which writes the values to a database. So far No problems. But..
step3: Now I want to 'post' these values again to another page without any user interaction.
My ideas were:
1) I know you can get the form values from Request.Form("myVar"), so I thought of making a 'dummy' form and setting the 'values' of the form variables to these Request.Form("myVar") valiables, but I don't know how to 'submit' them to another page again.
i have a series of .asp pages that i am dividing into model, view, control logic. my view collects a whole bunch of data and posts it to the controller. im wondering if there is a way to somehow "re-post" this same data to my model page.
in short, is .asp capable of taking data posted to a page and re-post that same data to another page?
I've an html form with some fields, I have to normally post them clicking a submit button to an asp page; this page have to programmatically repost these fields and other constants to another page
I do this beacuse I don't want the web user to see the costants which are the authentication values (username password)
I couldn't get my page to POST to my server I thought because I had run IIS lockdown and other hardening tools. Now I've rebuilt the whole server from scratch and have yet to disable anything. I still can't POST. GET has been working fine all along. Is there anything that needs to be done beyond setting the forms method to POST and using Request.Form(whatever), instead of Request.QueryString (whatever)? Is there something that I need to put in the ASP or client page header or something? I must be missing something. Maybe IIS 5 needs to be set up to use POST or something.
I'm trying to make a simple ASP page post to a URL on a seperate web site, and then get the returned HTML into a string which on service side script I can then parse. Is there any object built into IIS or Microsoft I could use Server.CreateObject with to make this possible?
I have a form that get submitted. On the page that dose the db work I need a loop that will run through each record set and updated it to the db. I was thinking about writing a do loop that will increment scount = scount + 1 . the problem is that I have no idea how to tell if i am at the end of my request.form("id").
i can response my request.form("id") and i see all the id's listed acress the page.. just need to loop through then one at a time.
Well I did a little research of my own and found that get shouldn't be used when a form is causing some big changes into the DB such as deleting, updating etc.
Until now I've always used GET for everything. So should I use Post for updating, deleting editing etc and GET only for retrival.