method pattern.get_string_segments
Contract
Return typewob
Parameter keyDefault valueType
a_stringreq
returns"first"type.<one_of "first" "last" "all"/>
Water Contract
<method pattern.get_string_segments
  a_string=req
  returns ="first"=<type.one_of "first" "last" "all"/>/>

See also: string_segment, replace_string_segments

Create a nested set of string segments for a given pattern and input string.

a wob
Parameter keyDefault valueType
_subjectfalse
The pattern, contining pattern.named subpatterns to match against the a_string argument.

a wob
Parameter keyDefault valueType
a_stringreq
The input string which the segments will be from.

a wob
Parameter keyDefault valueType
returns"first"type.<one_of "first" "last" "all"/>
How much of the string to grab segmetns of.

a wob
returns="first"
The default. Match against the first occurance of the _subject pattern in a_string. Here we let returns default to "first". Even though there are two subsstrings of the input string that match our pattern, "barhey" and "foohey", only the first of them is even attempted to match because returns="first". Our returned string segment matches the pattern "barhey" and thus has "barhey" as its a_string value. There is just one named subpattern to this pattern, named "fb" that matches "bar". That sub-string_segment is named after the subpattern that it mateches, namely "fb". (It could have also mathed "foo".) The top level string_segment when using returns="first" ( or "last") is always named "inner_whole". ("outer_whole" is used for returns="all".)
<pattern pattern.<named "fb" <one_of "foo" "bar"/>/> "hey"/>.
    <get_string_segments "barheyjunkfoohey"/>
<string_segment name="inner_whole" start=0 end=6 a_string="barhey" <string_segment name="fb" start=0 end=3 a_string="bar"/>/>
a wob
returns="last"
Similar to returns="first" but matches against the last occurance of the pattern in the input string.
<pattern pattern.<named "fb" <one_of "foo" "bar"/>/> "hey"/>.
    <get_string_segments "barheyjunkfoohey" returns="last"/>
<string_segment name="inner_whole" start=10 end=16 a_string="foohey" <string_segment name="fb" start=10 end=13 a_string="foo"/>/>
a wob
returns="all"
Returns an "inner_whole" named string_segment for each occurance of the _subject pattern. These are 'sub' string_segments of string_segment named "outer_whole" that represents the entire input string.
<pattern pattern.<named "fb" <one_of "foo" "bar"/>/> 
         pattern.<named "what_the_hey" "hey"/>/>.
   <get_string_segments "barheyjunkfooheytrashbar" returns="all"/>
<string_segment name="outer_whole" start=0 end=24 a_string="barheyjunkfooheytrashbar" <string_segment name="inner_whole" start=0 end=6 a_string="barhey" 
                        <string_segment name="fb" start=0 end=3 a_string="bar"/> 
                        <string_segment name="what_the_hey" start=3 end=6 a_string="hey"/>
                   /> <string_segment name="inner_whole" start=10 end=16 a_string="foohey" 
                        <string_segment name="fb" start=10 end=13 a_string="foo"/> 
                        <string_segment name="what_the_hey" start=13 end=16 a_string="hey"/>
                   />/>

Note that the named patterns to match must be immediate sub-patterns of the _subject pattern.