Hi Paul,
you could always just use RegEx in VFP:
oRE = CreateObject("VBScript.RegExp") oRE.Pattern = "\(([0-9.]*)\)$" ? oRE.Test(acid1) ? oRE.Test(acid2)
That said, I haven't played with that pattern, but it doesn't return your desired result.
wOOdy
-----Ursprüngliche Nachricht----- Von: ProFox profox-bounces@leafe.com Im Auftrag von Paul Newton Gesendet: Montag, 12. Dezember 2022 14:10 An: profox@leafe.com Betreff: Help with a regular expression
Hi all
I've been very quiet for a while so I thought it was about time I chimed in again. I have come across the use of a regex expression in another language which works like this:
acid1 = "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)" acid2 = "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid"
NumberAtEnd:= proc(S::string) description "Extract a parenthesized number, possibly containing periods, from the end of a string": local r; if StringTools:-RegMatch("\(([0-9.]*)\)$", S, r$2) then r else FAIL fi end proc:
NumberAtEnd(acid1) returns "2.13" NumberAtEnd(acid2) returns "FAIL"
How can this be done in VFP? Many thanks
Paul Newton ***
*
[excessive quoting removed by server]