|
|
I am looking for a way of removing instances of a web address/URL from an amount of text, where the URL is in the format
<a href="http://www.something.com">Site Description</a>
and replacing/reformatting the text (for a text only newsletter) into a form like
Site Description - www.something.com
I am running WSH 5.0 - so some advanced regular expression features are out....any other ideas on how this could be achieved??
|
|
|
|
|
The RegExp object was added to VBScript in version 5, and to JavaScript in version 3.
Just of the top of my head, you need something like:
<a\s[^>]*?href=['"]([^'">]*?)['"][^>]*?>(.*?)</a>
to be replaced with:
$2 [$1]
(with IgnoreCase = True, Global=True, MultiLine = False)
|
|
|
|
|
i have this code:-
sub goodMSG(msg)
Dim badwords
badwords = Array("arse")
For i=0 to badwords.length
wen run on my IIS server on my ocmp, it gives the error:-
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'badwords'
having only had 3hrs experience of VB, i ave not got a clue as to why this is happening.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "What goes up must come down. Ask any system administrator"
|
|
|
|
|
Could you post more of the code? The following runs fine on my IIS dev server (NT4 Server)...
Sub goodMSG(msg)
Dim badwords
badwords = Array("arse")
For i=0 To badwords.length
...
Next
End Sub
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds."
"Remember in this game we call life that no one said it's fair."
"Just because you're winnin' don't mean you're the lucky ones."
Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses
|
|
|
|
|
|
Hehe, I forgot to change to VB mode, but I figured it out when I noticed your return statements. I take it your coming from JScript, eh?
There is not a length property for an array object like in JScript. VB instead has two functions called LBound() and UBound() to find the lower and upper index bounds of the array.
Also, get rid of your return statements. To return a value you'll need to use a function and not a subroutine because subs don't return values by design. To return a value in VBScript and VB set the name of the function to the value just as you would a variable. To leave the function early you can call exit function .
Here's a short VB version of your function...
<%@ Language=VBScript %>
<%
Function GoodMsg(msg)
Dim badwords, temp
badwords = Array("arse", "a***hole")
' test the text before removing characters.
For i=0 To UBound(badwords)
temp = InStr(msg, badwords(i))+1
If temp > 1 Then
GoodMsg = False
Exit Function
End If
Next
' if we get here all went well
GoodMsg = True
End Function
' test the messages
Response.Write GoodMsg("Nice arse.")
Response.Write GoodMsg("Nice booty.")
%>
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds."
"Remember in this game we call life that no one said it's fair."
"Just because you're winnin' don't mean you're the lucky ones."
Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses
|
|
|
|
|
yep, i did come from Javascript, actually, i originally wrote the code in PHP, then converted it to javascript, now im converting it to VB.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "What goes up must come down. Ask any system administrator"
|
|
|
|
|
|
I was excited to see an autoComplete combobox in vb.net by Daryl on code project. I quickly began to try to reproduce the functionality in C# and on a web form. It went nowhere fast. No KeyUp event for dropdownlist, no Leave event for dropdownlist........ Has anyone managed to produce an autocomplete combobox for a web form? I am desperate.
|
|
|
|
|
If you're desperate...
http://www.dbcombo.net/
Not really an Autocomplete, more like an AutoSugguest.
I personally use an AutoCompleting combobox that depends only on IE5.5 DHTML so it doesn't really satisfy a c# requirment.
Depending on your target audience you could embed an inherited WinForms ComboBox, but that kind of goes in the direction of DHTML, no ASP.NET interaction.
|
|
|
|
|
Where did you get the dhtml. I have tried several things. I currently use the combobox that I believe is Forms 2.0 from Access.
|
|
|
|
|
Yeah I've used that one before... Pretty good except it works funky (I think all the controls in that library arent supported unless their hosted on an Office Style UserForm). Like after using the combobox you have to click buttons twice for the OnClick Event to fire.
Anyways this is a home-grown ComboBox implimented as an Element Behavior. I can email it to you if you'd like.
|
|
|
|
|
I would like. Seems I have tried that. The one I used worked good but when the page loaded, it flashed all the html to build the box. I have about 3000 entries.
|
|
|
|
|
|
Yes I did. Thank you very much. The code seems to be quite complex and I am not very fluent in behaviors. I have not gone thru it yet but hopefully I can do that this week. Thanks again. I still want to explore the C# server control solution but apparently not many people know the answer. I am very dissappointed that MS only provides ONE EVENT for the web form control. I cannot believe this is not possible. Any answers welcome. Thanks again Chris.
|
|
|
|
|
It's understandable to be dissapointed with the lack of events from the DropDownList and other web and html controls that ASP.NET expose, but then again its the nature of the environment. Every event that fires on server objects requires a postback. You could imagine how impractical it would be to make a round trip back to the server every time a user pressed a key or ran the mouse over a control.
|
|
|
|
|
I need to search a variable for a string, but do not know how. can someone help me.
oh, and does anyone know a good reference site of asp functions?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "What goes up must come down. Ask any system administrator"
|
|
|
|
|
Try the InStr function.
A good reference site is the MSDN site(http://msdn.microsoft.com). For ASP/VBScript check out the Scripting section of MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp) or the Active Server Pages.
/WW
|
|
|
|
|
|
strReverse() should do it:
a = strReverse("ABC")
/WW
|
|
|
|
|
just one more question, how to remove any characters from the string that are not normal characters (e.g. a-z)
if you are wondering why I am asking all these Q's, is because I made some code in PHP, i converted it to Javascript for codeproject, and was gonna convert it to asp for codeproject, only problem is, I dont know any asp.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "What goes up must come down. Ask any system administrator"
|
|
|
|
|
|
I have copied the following code off phpbuilder.com but cannot find anything similar for stripping HTML comments...
I'm assuming the posix regex is the same across the board and was hoping someone out there in CP land (seeing how I don't seem to be getting answered at PHP sites) could possibly help me...
$buffer = eregi_replace("<script[^>]*>.*</script>","",$buffer);
Where is my regex going wrong in the comments stripping...?
Anyone help...thanx...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
Where is my regex going wrong in the comments stripping...?
I don't see anything wrong with it off the top of my head, but try escaping the exclamation mark just to be safe. And, of course, I'd like to know what you find out so I'll know for future reference.
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds."
"Remember in this game we call life that no one said it's fair."
"Just because you're winnin' don't mean you're the lucky ones."
Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses
|
|
|
|