ASP equivalent to PHP ereg_replace function

I’ve used so many time the php function ereg_replace that when I have to use ASP (‘cause sometimens you have…

Novembre 10, 2009

I’ve used so many time the php function ereg_replace that when I have to use ASP (‘cause sometimens you have to use that old terrible language) I have to use it also in ASP.
I’ve also read on PHP site that this function will soon became depracated. I’m sad about that.
But in Microsoft ASP language ereg_replace doesn’t exists, so, here it is ASP equivalent to PHP ereg_replace:

function ereg_replace(pattern,change,str)
	Dim ObjRegexp
	Set ObjRegexp = New RegExp
	ObjRegexp.Global = True
	ObjRegexp.IgnoreCase = True
	ObjRegexp.Pattern = pattern
	str = ObjRegexp.Replace(str,change)
	Set ObjRegexp = Nothing
	ereg_replace = str
end Function

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

Recommended

ASP equivalent to PHP strip_tags

I’ve found those functions around in the internet and I put them here just to remind how to strip tags…

Febbraio 9, 2010

Highlight text for search results in PHP

Useful code to highlight text occurences in search results or in a text. How to highlight text in a string…

Settembre 2, 2016

How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

Settembre 22, 2015

Block junk emails, spammers and temporary emails

If you need an Email Validator Function, consider this version that includes also the check against common temporary mail services…

Dicembre 3, 2013

How many times a web link has been shared on Twitter

Twitter share button and Facebook share button are the most used buttons to share links on Internet. You can read…

Ottobre 19, 2012

get MySpace events with a PHP function

Here is a function to read the concerts for a myspace band page. This code retrieves the “shows page” for…

Febbraio 21, 2011