Re: collect string from string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2010-04-22 at 23:41 +0600, saeed ahmed wrote:

> hello friend,
> 
> I have a string like below
> "
> 
> ===Pronunciation===
> * {{enPR|tē}}, {{IPA|/tiː/}}, {{SAMPA|/ti:/}}
> * {{audio|en-us-tea.ogg|Audio (US)}}
> * {{audio|En-uk-tea.ogg|Audio (UK)}}
> *: {{rhymes|iː}}
> * {{homophones|T|te|tee|ti}}
> 
> 
> # {{uncountable}} The dried leaves or buds of the [[tea plant]],
> ''[[w:Camellia sinensis|Camellia sinensis]]''.
> #: ''Go to the supermarket and buy some '''tea'''.''
> # {{uncountable}} The drink made by [[infuse|infusing]] these dried
> leaves or buds in hot water.
> ====Usage notes====
> In the [[United Kingdom]], [[Canada]], other English speaking
> [[Commonwealth]] countries, and in northern areas of the [[United
> States]], ''tea'' is assumed to mean [[hot]] tea and is usually served
> in a [[teapot]] with separate [[cup]]s, or sometimes served directly
> in cups such as for large groups or for [[takeout]].
> 
> In southern areas of the United States, ''tea'' is assumed to mean
> [[iced tea]] and is usually served with ice, either in a [[pitcher]]
> with separate [[glass]]es or directly in glasses.
> 
> Strictly speaking, "tea" has been reserved for [[infusion]]s made from
> leaves of ''[[w:Camellia sinensis|Camellia sinensis]]''. Infusions
> made from other [[herb]]s such as [[rooibos]], [[mint]]{{,}} and
> [[chamomile]] are called [[tisane]]s. In recent years the word "tea"
> has been extended to include the herbal infusions.
> 
> ====Synonyms====
> * {{italbrac-colon|dried leaves of tea plant}} [[tea leaves]]
> * {{italbrac-colon|drink made by infusing parts of various other
> plants}} [[herb tea]], [[herbal tea]], [[infusion]], [[tisane]]
> 
> ====Derived terms====
> 
> "
> 
> now I want to collect only the string which are start with '#'. how
> can I do this? please suggest me.
> 
> 
> -----
> Regards
> Saeed Ahmed
> http://saeed05.wordpress.com
> -----


If the text is in a file, use file() to read the contents into an array
and then check the first character.

Alternatively, if the text is in a string, you could use a regex to pull
out only matching lines. This is an untested regex, but it should do the
trick:

/^(\#.+)$/g

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux