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: 25
Default Searching for a substring inside another string - there has to be an easier way!

Hi. I'm looking for ans instance of the substring "tab" inside an
rcvdPack string, but I need to be sure it matches a whole word only, so
if it finds "tablets", "tabs", "protetab", or "taberculosis" it mustn't
replace those. I'm checking if a char before T and char after B is
different from a lowercase letter, but I think for what it does there
should be ans easier method. The mostly are spaces before T and after
B, but there might be brackets, fullstops, asterisks, etc. Sometimes
the the word TAB is put at the end of the rcvdPack that's why I check
the k + 2 = Len(rcvdPack)

That's my code:


k = InStr(1, rcvdPack, "tab") ' replace TAB but not where TABS is
present
If k 0 Then
If Not Asc(Mid(rcvdPack, k - 1, 1)) < 97 And Not
Asc(Mid(rcvdPack, k - 1, 1)) 122 Then
'
Else
If k + 2 = Len(rcvdPack) Then
rcvdPack = Replace(rcvdPack, "tab", "tablets")
ElseIf Not Asc(Mid(rcvdPack, k + 3, 1)) = 97 And Not
Asc(Mid(rcvdPack, k + 3, 1)) <= 122 Then
rcvdPack = Replace(rcvdPack, "tab", "tablets")
End If
End If
End If


Any ideas?

Cheers

 
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
Searching for a string of text inside a column Steve W. Excel Worksheet Functions 5 March 5th 09 04:52 PM
Substring to replace string Andrew Slentz[_2_] Excel Programming 3 June 11th 04 06:54 PM
Substring to replace string Andrew Slentz[_2_] Excel Programming 1 June 11th 04 04:51 PM
Searching for a substring in a range mrimah Excel Programming 0 May 2nd 04 11:18 AM
How to get rid of string which contain a substring like 'PO BOX'. dukejas[_4_] Excel Programming 2 November 11th 03 02:36 AM


All times are GMT +1. The time now is 07:27 AM.

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

About Us

"It's about Microsoft Excel"