wife's grandson's wife
lets say I have a relation like that in my file.
there are two instances of wife.
I want to capture the second one..
it seems like I might need to use string.gmatch but cannot figure it out.
currently I use:
local _fwife = string.match(_0fr.RLT, '(wife)')
and it captures and returns the first.
* pattern matching
pattern matching
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28414
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: pattern matching
Pattern matching is not the solution. It is just like all the earlier discussions about 'instances'.
i.e. An Individual's 1st Occupation is INDI.OCCU[1] and their 2nd Occupation is INDI.OCCU[2]
So an Individual's 1st Spouse is INDI.FAMS[1]>WIFE> and 2nd Spouse is INDI.FAMS[2]>WIFE>
or there is the shortcut for 1st Spouse INDI.~SPOU[1]> and 2nd Spouse INDI.~SPOU[2]>
(That shortcut works for both men and women to find their wife or husband.)
i.e.
local ptrWife = fhGetItemPtr( ptrHusb, "~.FAMS[2]>WIFE>" )
or
local ptrWife = fhGetItemPtr( ptrHusb, "~.~SPOU[2]>" )
i.e. An Individual's 1st Occupation is INDI.OCCU[1] and their 2nd Occupation is INDI.OCCU[2]
So an Individual's 1st Spouse is INDI.FAMS[1]>WIFE> and 2nd Spouse is INDI.FAMS[2]>WIFE>
or there is the shortcut for 1st Spouse INDI.~SPOU[1]> and 2nd Spouse INDI.~SPOU[2]>
(That shortcut works for both men and women to find their wife or husband.)
i.e.
local ptrWife = fhGetItemPtr( ptrHusb, "~.FAMS[2]>WIFE>" )
or
local ptrWife = fhGetItemPtr( ptrHusb, "~.~SPOU[2]>" )
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: pattern matching
Mike,
you misunderstand me, as I said before its a relation; i.e it is returned from fhBIF 'Relationship' 'TEXT' it is a string, and not family pointers.
My mother married twice.
first husband they had a daughter.
that daughter had a son, and he married. (grandson and wife)
my father and mother got married and here I am! not germaine to the issue, just placing things in spacetime.
when I look at the wife of that grandson of my mother -- (and to my mother: grandson's wife) with relationship he is; to my father: wife's grandson and his wife is relation to my father: wife's grandson's wife.
so where the relation is: wife something wife or husband something husband I need to ferret out the second instance.
you misunderstand me, as I said before its a relation; i.e it is returned from fhBIF 'Relationship' 'TEXT' it is a string, and not family pointers.
My mother married twice.
first husband they had a daughter.
that daughter had a son, and he married. (grandson and wife)
my father and mother got married and here I am! not germaine to the issue, just placing things in spacetime.
when I look at the wife of that grandson of my mother -- (and to my mother: grandson's wife) with relationship he is; to my father: wife's grandson and his wife is relation to my father: wife's grandson's wife.
so where the relation is: wife something wife or husband something husband I need to ferret out the second instance.
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28414
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: pattern matching
You are correct ~ I don't understand.
You did not say you were using the Relationship() function. How was I supposed to guess that?
I don't see where there is the 2nd instance of a wife. Your mother has two instances of a husband.
You will need to explain in more detail what you are trying to achieve with a snippet of code showing where you are stuck.
Are you saying you want to find the wife of your mother's grandson?
You must already have that pointer as a parameter to the Relationship() function.
The other pointer is to your father.
So it provides the relationship "wife's grandson's wife".
You did not say you were using the Relationship() function. How was I supposed to guess that?
I don't see where there is the 2nd instance of a wife. Your mother has two instances of a husband.
You will need to explain in more detail what you are trying to achieve with a snippet of code showing where you are stuck.
Are you saying you want to find the wife of your mother's grandson?
You must already have that pointer as a parameter to the Relationship() function.
The other pointer is to your father.
So it provides the relationship "wife's grandson's wife".
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: pattern matching
rlt = 'wife's grandson's wife'
rlt = 'wife's brothers wife'
and so on...
lets say I have a relation like that in my file.
when I scan the string rlt, I want to capture only the second instance of wife. I already can get the first one.
in general where there are 2 instances of a word (or partial word... and it can be any word in a string.. ) repeated in a string I want to know the 2nd one is there. the second is important to me, the first is not.
local rr = rtvRLT(ptr)
local husb = string.match(rr.RLT, '(husband)')
local wife = string.match(rr.RLT, '(wife)')
husb does not exist, that is good.
wife does exist, but it picked the first one, which I dont care about, I want it to exist on the second one.
rlt = 'wife's brothers wife'
and so on...
lets say I have a relation like that in my file.
when I scan the string rlt, I want to capture only the second instance of wife. I already can get the first one.
in general where there are 2 instances of a word (or partial word... and it can be any word in a string.. ) repeated in a string I want to know the 2nd one is there. the second is important to me, the first is not.
local rr = rtvRLT(ptr)
local husb = string.match(rr.RLT, '(husband)')
local wife = string.match(rr.RLT, '(wife)')
husb does not exist, that is good.
wife does exist, but it picked the first one, which I dont care about, I want it to exist on the second one.
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28414
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: pattern matching
Ah! Now I understand.
local rr = rtvRLT(ptr)
local husb = string.match(rr.RLT, 'husband.+(husband)')
local wife = string.match(rr.RLT, 'wife.+(wife)')
i.e. the pattern requires the word then any characters .+ and finally captures 2nd (word) if it exists.
local rr = rtvRLT(ptr)
local husb = string.match(rr.RLT, 'husband.+(husband)')
local wife = string.match(rr.RLT, 'wife.+(wife)')
i.e. the pattern requires the word then any characters .+ and finally captures 2nd (word) if it exists.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry