Quote:
Originally posted by nmsinghe
I have to solve a programming problem for my wife who is engaged in Research in Breast Cancer.
1. She has frequently to search a long single line of alphabetic characters (lower case) for an exact match of a string.
e.g. mwaaagglwrsraglralfrsrdaalfpgcerglhcsavscknwlkkfasktkkkvwyespslgshstykpskleflmrstskktrkedharlralngll ykaltdllctpevsqelydlnvelskvsltpdfsacraywkttlsaeqnahmeavlqrsaahmslisywqsqtldpgmkettlykmisgtlmphnpaapq srpqapvcvgsimrrstsrlwstkggkikgsgawcgrgrwls
2. The ONLY two strings to be searched for are -
r-r--s
r-r--t
The - can be any of the following characters
acdefghiklmnpqrstvyz
3. Once an exact match has been made it is essential to know the number of characters from the start of the line inclusive of the 6 character string.
Can anyone suggest a program or script.
It is urgent.
Thanks
Nev
well something like the following pattern match can be used.
/r[acdefghiklmnpqrstvyz]r[acdefghiklmnpqrstvyz][acdefghiklmnpqrstvyz][s|t]/
useing perls index() or substr() would prolly be the best way to go i think. I know i will work on this tommarow just to knwo for myself how to do it. but i will be excited to see what others come up with befor i can post again.
this gives me something to think about tonight. heh
mmm some of the logic in this would be like so if index is used.
load the string into the index function.
index will find a "specified" number of occurances. always going with the left most unless otherwise specified. (so if there are 2 found strings i am at a loss. unless you take the return value of the index and load that into another index search and use the return value as a starting position, and or incromenting the occurance rateing. tossing this in a loop till the end of string.
the return value of the index search is the # of characters till a match is found. so that should fulfill your request.
what do you guys think?