Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68697?pagenum=1
05 November 2025, 09:23
Topic
bobby131313
Using Regex in a replace function?
12 June 2009, 11:30
I've taught myself quite a bit using the replace function but now I'm stumped. I have a string I want to blank, but within the string is a string that changes randomly. Example....
lnk.Description = Replace(lnk.Description, "constantconstantchangesrandomlyconstantconstant", "")
The part in bold can vary in the number of characters also, can this be done using Regex... or something?
TIA!
Replies ...
Shaggy
12 June 2009, 11:42
Code:
dim objRegex set objRegex=new RegExp objRegex.ignorecase=true objRegex.global=true objRegex.pattern="constant1(.+?)constant2" lnk=objRegex.replace(lnk,"") set objRegex=nothing
bobby131313
12 June 2009, 12:13
Ooooooooooohhhh....... That's a beautiful thing... Thanks!
Shaggy
12 June 2009, 12:29
You're welcome, Bobby You can teach yourself regular expressions here and then use this for local testing.
bobby131313
12 June 2009, 12:35
I've bookmarked them thanks!
AnonJr
12 June 2009, 16:08
I saw this and immediately thought of this article... He's got a few other articles that round it out if you're in the reading mood.