-
June 27th, 2011, 08:31 PM
#1
String Pattern Matching
I'm trying to do a simple Replace() on a string that contains dynamic content within (the time output). Example:
Code:
Last message received on 6/26 at 10:35 PM
How can I refer to the time when it's constantly changing?
Code:
strTemp = Replace(strTemp, "Last message received on " & (SOME COMPARISON MAGIC GOES HERE), "")
I looked into the "Like" operator but I don't think a Boolean return value would help me here. Thanks!
-
June 27th, 2011, 10:01 PM
#2
Re: String Pattern Matching
Always use [code][/code] tags when posting code.
-
June 27th, 2011, 10:04 PM
#3
Re: String Pattern Matching
You could also use the Instr() function to find the position of "Last message received on" and then parse out the required number of characters using Right$() and Left$() or MID$() functions.
Always use [code][/code] tags when posting code.
-
June 28th, 2011, 12:42 AM
#4
Re: String Pattern Matching
I solved my problem using this Regular Expression (& late binding, of course ):
Code:
'Create our regular expression object which matches the example: 6/26 at 10:35 PM
Set reLastMsg = CreateObject("VBScript.RegExp")
With reLastMsg
.Pattern = "\d{1,2}.\d{1,2}\s\w{2}\s\d{1,2}:\d{2}\s\w{2}"
.Global = True
.IgnoreCase = True
End With
-
June 28th, 2011, 10:57 AM
#5
Re: String Pattern Matching
Please mark your thread Resolved
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|