String & delimit
Dié
d.cavadini at freesurf.ch
Tue Apr 3 09:54:58 PDT 2007
Pragma Wrote:
> Dié wrote:
> > Hello
> >
> > I have this string:
> >
> > blablabla thisis a string example <i_need_this_text>
> >
> > With Tango.text.Util i think i can use "delimit" function for extracting the test "i_need_this_text".
> >
> > delimit("blablabla thisis a string example <i_need_this_text>","<>")
> >
> > But i found in http://www.dsource.org/projects/tango/docs/current/tango.text.Util.html
> >
> > the delimit declaration:
> >
> > T[][] delimit (T)(T[] src, T[] set);
> >
> > and now how can i correctly use this function with template? I suppose i must declare e template like this
> >
> > template TText(T){alias T* t;}
> >
> > but i dont understand how use the template with the delimit function.
> >
> > Someone can explain me?
> > Thank you!
> >
>
> First of all, the template uses Inline Function-Template Instantiation (IFTI); the compiler will *deduce* what 'T' is
> based on the arguments you pass to delimit(). Just call it like "delimit(string1,string2)" and it'll work fine.
>
> Second, let's look at the documentation for the delimit() function:
>
> > # T[][] delimit (T)(T[] src, T[] set);
> > Split the provided array wherever a delimiter-set instance is found,
> > and return the resultant segments. The delimiters are excluded from
> > each of the segments. Note that delimiters are matched as a set of
> > alternates rather than as a pattern.
>
> Arguably, this is not the best description in the world. It makes much more sense after seeing an example of what it does:
>
> auto x = delimit("One,Two;Three.Four&Five",",;.&");
>
> The variable x will now be an array of strings, containing "One","Two","Three","Four", and "Five" in that order. It's
> important to note that the second argument of the delimit() function is used as a series of single-character delimiters
> that are used to split up the source string. The delimiters themselves are not returned.
>
> --
> - EricAnderton at yahoo
Thank you Pragma,
before posting my problem i have read the doc. and i have tried with
"delimit(string1,string2)" (directly with char type)
but after your post i think my problem is another....
mmm i wont to discover this new problem now!
Thank you, bye
More information about the Digitalmars-d
mailing list