acid1 = "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)"
acid2 = "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid"

string = acid1
store '(' to left_str
store ')' to right_str
pos1 = rat(left_str, string)
pos2 = rat(right_str, string)
? SUBSTR(string,pos1+1,pos2-pos1-1)

"2.13"


string = acid2
store '(' to left_str
store ')' to right_str
pos1 = rat(left_str, string)
pos2 = rat(right_str, string)
? SUBSTR(string,pos1+1,pos2-pos1-1)

"methylsulfanyl"

On 12/12/2022 14:12, Virgil Bierschwale wrote:
it would, because it would return a string instead of a numeric value, but
I like the more elaborate ones that I'm seeing.



On Mon, Dec 12, 2022 at 8:01 AM Paul Newton <paul.newton.h...@gmail.com>
wrote:

Thanks Virgil

I am not sure if your suggestion works in the case of "Methionine =
(S)-2-amino-4-(methylsulfanyl)-butanoic acid".  I suspect it would end
up as "methylsulfanyl" but I haven't tested it yet.

Paul


On 12/12/2022 13:48, Virgil Bierschwale wrote:
you can do this to get the positions, and then just get what is between
the
two positions.

store "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)"
to
string
store '(' to left_str
store ')' to right_str

*acid2 = "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid"

clear

? rat(left_str, string)
? rat(right_str, string)



On Mon, Dec 12, 2022 at 7:10 AM Paul Newton <paul.newton.h...@gmail.com>
wrote:

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/e6bb73a6-52e2-82e8-1413-09ce01f68...@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