Hi wOOdy

Thanks for both your replies.  I am not sure if it can be done at all using VBScript.RegExp but it would be nice if it could. Your AcidTest function has a problem with cDummy ...

Paul



On 12/12/2022 13:42, Jürgen Wondzinski wrote:
Hi Paul,

this would be a pure VFP solution:
**********************************************
? AcidTest("Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)")
? AcidTest("Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid")

FUNCTION AcidTest(cText)
LOCAL cResult, nCount

nCount  = OCCURS("(", cText)
cResult = STREXTRACT(cText, "(", ")", nCount)
IF LEN(CHRTRAN(cDummy, "0123456789.", "")) # 0
        cResult ="FAIL"
EndIf
Return cResult
  **********************************************

wOOdy


-----Ursprüngliche Nachricht-----
Von: ProFox <profox-boun...@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]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/4f4d3cc6-1741-9340-75df-de0a6d491...@gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to