LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Test for exact match in string

OK, this one is really getting to me. Without using Excel specific
functions, how can I test if I've found the exact match of a word or phrase?
I've came up with the code below, which works great in most cases (Test1 and
Test2). My problem is I could be testing html source code (Test3). My head
hurts, so I post here in hopes of some help. Thanks!


Sub tester()
Dim vSplit As Variant
Dim bExactMatch As Boolean
Dim sTest1 As Variant
Dim sTest2 As Variant
Dim sTest3 As Variant


sTest1 = "this is a test, here's the stuff you wanted. "
vSplit = Split(sTest1, " here's ")
bExactMatch = UBound(vSplit) < 0
Debug.Print "Test1: " & bExactMatch

sTest2 = "this is a test, there's the stuff you wanted. "
vSplit = Split(sTest2, " here's ")
bExactMatch = UBound(vSplit) < 0
Debug.Print "Test2: " & bExactMatch

sTest3 = "<bhere's</b the stuff you wanted. "
vSplit = Split(sTest3, " here's ")
bExactMatch = UBound(vSplit) < 0
Debug.Print "Test3: " & bExactMatch

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Exact Match using INDEX, MATCH DoubleUU Excel Worksheet Functions 3 August 15th 08 02:42 PM
vlookup and finding text string that's not an exact match my Excel Discussion (Misc queries) 4 July 31st 07 05:04 PM
TEST FOR EXACT TEXT Phil B Excel Worksheet Functions 8 October 29th 06 11:51 PM
Calculating p-value from Fisher's Exact Test for XYZ parameters paulinoluciano Excel Worksheet Functions 0 April 18th 06 12:38 PM
Calculating p-value from Fisher's Exact Test Ian Smith Excel Worksheet Functions 1 September 28th 05 08:00 PM


All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"