Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SUBSTR() by taking care of upper characters
Message
From
18/01/2003 23:29:30
 
 
To
17/01/2003 18:33:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00743063
Message ID:
00743217
Views:
18
Regular expressions can do this and much more.
lcHtml = "But, it may well be that Michel would be found as MICHEL" + ;
" and with a mix a case characters. So, is there a way with STRTRAN()" + ;
" to handle that. What I am looking for is to have all kind of occurences" + ;
" of Michel to be replaced by Michel Fournier. Even if MICHEL is uppercase" + ;
" or other variations, I want it to be replaced Michel Fournier. Can " + ;
"STRTRAN() do it or do I have to build a custom function for that?"

? lcHtml

loRegExp = CreateObject("VBScript.RegExp")	&& Create regular expression object
loRegExp.Pattern = "michel"					&& Set the pattern
loRegExp.Global = .t.
loRegExp.IgnoreCase = .t.					&& Make case insensitive
loRegExp.Multiline = .t.
lcHtml = loRegExp.Replace(lcHtml, "Michel Fournier")	&& Make replacement.

? lcHtml
>I have faced that situation at several occasions and I was wondering if there would be a simpler way to do that.
>
>I use STRTRAN() to look up for specific strings within a string. Then, I want to replace it with something else. For example, I might do this:
>
>
>lcHtml=STRTRAN(lcHtml,'Michel','Michel Fournier')
>
>
>But, it may well be that Michel would be found as MICHEL and with a mix a case characters. So, is there a way with STRTRAN() to handle that. What I am looking for is to have all kind of occurences of Michel to be replaced by Michel Fournier. Even if MICHEL is uppercase or other variations, I want it to be replaced Michel Fournier. Can STRTRAN() do it or do I have to build a custom function for that?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform