| C++ºô´õ Æ÷·³ |
|
|
|
|
|
|
|
| º¼·£µåÆ÷·³ Ȩ |
|
|
|
|
|
|
|
|
|
|
|
| ȸ¿ø ¸Þ´º |
|
|
 |
|
|
|
|
 |
|

|
|
| [199] [Boost »ìÆìº¸±â] 7. String Algorithm2 |
|
Lyn [tohnokanna]
|
1767 ÀÐÀ½ 2009-05-20 10:43 |
¿øº»Ãâó : http://lunapiece.net/3814
À̹ø¿£ °ø¹é ó¸® ÇÔ¼öµéÀÌ´Ù. ·Î±×ÀÎÇÒ¶§ ¾ÆÀ̵ð 󸮶ó´øÁö¿¡ ½á¸ÔÀº ±â¾ïÀÌ ÀÖ´Ù : )
#include <cstdio>
#include <string>
#include <boost/algorithm/string.hpp>
using namespace boost;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string str1 = " I love Lyn! ";
string str2;
trim(str1); //¾ç¿·Àǰø¹éÀ»´ÙÁ¦°ÅÇÑ´Ù.
printf("trim : %s\n", str1.c_str());
str1 = " I love Lyn ";
str2 = trim_copy(str1); //¾ç¿·Àǰø¹éÀ»´ÙÁ¦°ÅÇϵǿøº»À»º¯°æÇÏÁö¾Ê°í»õ·Î¿î¹®ÀÚ¿À»¸®ÅÏ
printf("trim_copy : %s, %s\n", str1.c_str(), str2.c_str());
str1 = "####### I love Lyn #######";
trim_if(str1,is_any_of("#")); //Á¦°ÅÇÒ¹®ÀÚ¸¦Á÷Á¢ÁöÁ¤ÇؼÁ¦°ÅÇÑ´Ù.
printf("trim_if-1 : %s\n", str1.c_str());
str1 = "!@#!@#I love Lyn!@#!@#";
trim_if(str1,is_any_of("!@#")); //Á¦°ÅÇÒ¹®ÀÚ¿ÀDZæÀÌ¿¡´ÂÁ¦ÇÑÀ̾ø´Ù!
printf("trim_if-2 : %s\n", str1.c_str());
str1 = " I love Lyn ";
trim_left(str1); //¿ÞÂÊÀǰø¹éÀ»Á¦°ÅÇÑ´Ù.
printf("trim_left : %s\n", str1.c_str());
//¹°·Ðtrim_left_copy, trim_left_if, trim_right, trim_right_copy, trim_right_copy_if µîµî.. ÀÖÀ»ÇÔ¼ö´Â´ÙÀÖ´Ù.
//¿©±â¼´Â¸î°¡Áö¸¸¼Ò°¡ÇßÁö¸¸³×Àֱ̹ÔÄ¢À»º¸¸é´Ù¾Ë¼öÀÖÀ»¼öÁØÀÌ´Ù.
return 0;
}
|
°ü·Ã ±Û ¸®½ºÆ®
|