![]() |
|
|
|
#1 |
|
Given a string with some of the words in curly braces, how do I
extract the words within curly braces alone using regular expression? Also I wouldnt know how many such words within braces exist in my string...In such a case how do i extract all the words. $str = "My {name} is {anand} and i seek {your} help in this {problem}"; Anand, Anand |
|
|
|
|
#2 |
|
Posts: n/a
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 (Anand) wrote in news: om: > Given a string with some of the words in curly braces, how do I > extract the words within curly braces alone using regular expression? > Also I wouldnt know how many such words within braces exist in my > string...In such a case how do i extract all the words. > > $str = "My {name} is {anand} and i seek {your} help in this > {problem}"; Pretty straightforward: @words = $str =~ /\{([^}]*)\}/g; - -- Eric $_ = reverse sort qw p ekca lre Js reh ts p, $/.r, map $_.$", qw e p h tona e; print -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBPwvq9WPeouIeTNHoEQItDQCeI/yaVs4b6DGT9OoIqk0gBnRPrUoAoOhP AS1OnpTX8q7DQ0mPNWHJwpdH =WVph -----END PGP SIGNATURE----- |
|