Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String in a String Exact Match
Message
De
19/09/2007 17:45:35
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/09/2007 12:23:58
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01255518
Message ID:
01255630
Vues:
12
>I am tring to find a way to check for a string within a string but what I have came uo with is strill not working every time.
>
>I am using the AT() function but this fails if my:
>
>search expression is revJ
>and searched expression is 855956-401 revJ2
>
>J and J2 are two different revision levels.
>
>Sometimes searched expression can be more complex like:
>855965-401 revJ2, 855965-403 revJ2, 855965-405 revJ2
>
>Any ideas?

Steven,
I think using regular expressions would be easier than trying to do with VFP functions. As I understand you want to find "revJ" as a word. ie:
lcString = "855965-401 revJ2, revJ 85revJ 5965-403 and revJ, revJ2, 855965-405 revJ2"
oRX = Createobject("VBScript.RegExp")
With oRX
  .Pattern = "\brevJ\b"
  .IgnoreCase = .F.
  .Global = .T.
  Local loMatches
  loMatches = .Execute(m.lcString)
ENDWITH
_screen.FontName = "Courier New"
clear
? m.lcString
For Each loMatch In loMatches
	? PADL("^",loMatch.firstIndex+1)
*    ? loMatch.firstIndex + 1,loMatch.Value
ENDFOR

** And you could replace all matches with something else unique
** This one is using the pattern above
NewString = oRX.Replace(m.lcString, REPLICATE("%",LEN("revJ")))
? m.lcString
? m.NewString

** Or simply ask if exists with Test method.
? oRX.Test(m.lcString)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform