Using Regex in a replace function? - نوشته شده در (892 Views)
Senior Member
bobby131313
مطلب: 1163
1163
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!
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
Code:
dim objRegex
set objRegex=new RegExp
objRegex.ignorecase=true
objRegex.global=true
objRegex.pattern="constant1(.+?)constant2"
lnk=objRegex.replace(lnk,"")
set objRegex=nothing
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
نوشته شده در
Senior Member
bobby131313
مطلب: 1163
1163
Ooooooooooohhhh....... That's a beautiful thing... Thanks! bigsmile
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
You're welcome, Bobby smile
You can teach yourself regular expressions here and then use this for local testing.
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
نوشته شده در
Senior Member
bobby131313
مطلب: 1163
1163
I've bookmarked them thanks!
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
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.
 
شما باید یک متن وارد کنید