1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # LAB 9-5 Çлç ÄÚµå ÃßÃâÇϱ⿡ µµÀüÇÏÀÚ, 239ÂÊ # import re # ¸ÖƼ¶óÀÎ ÅؽºÆ®´Â ¼¼ °³ÀÇ µû¿ÈÇ¥¸¦ »ç¿ëÇÏ¿© Ç¥ÇöÇÑ´Ù text = '''101 COM PythonProgramming1 102 MAT LinearAlgebra 103 ENG ComputerEnglish''' # Python Part1°ú °°ÀÌ ¼ýÀÚ°¡ Ç¥ÇÔµÈ ¹®ÀÚ°¡ ÀÖÀ» °æ¿ì # ¾ËÆĺª ¹®ÀÚ³ª Áٹٲ޹®ÀÚ(\n)ÀÌ ¾Æ´Ñ ¼ø¼öÇÏ°Ô ¼ýÀڷθ¸ ÀÌ·ç¾îÁø ´Ü¾î¸¦ ÃßÃâÇÏ´Â Á¤±Ô½Ä s = re.findall('[^a-zA-Z\\n]\d+', text) print(s) # Çмö¹øÈ£°¡ ¹Ýµå½Ã ¼¼ÀÚ¸® Á¤¼öÀÏ °æ¿ì ´ÙÀ½°ú °°Àº ¹æ¹ýµµ °¡´ÉÇÔ s = re.findall('\d{3}', text) print(s) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # LAB 9-5 Çлç ÄÚµå ÃßÃâÇϱ⿡ µµÀüÇÏÀÚ, 239ÂÊ # import re # ¸ÖƼ¶óÀÎ ÅؽºÆ®´Â ¼¼ °³ÀÇ µû¿ÈÇ¥¸¦ »ç¿ëÇÏ¿© Ç¥ÇöÇÑ´Ù text = '''101 COM PythonProgramming1 102 MAT LinearAlgebra 103 ENG ComputerEnglish''' # 3°³ÀÇ ´ë¹®ÀÚ·Î ÀÌ·ç¾îÁø ´Ü¾î¸¦ ÃßÃâÇÏ´Â Á¤±Ô½Ä s = re.findall('[A-Z][A-Z][A-Z]', text) print(s) # 3°³ÀÇ ´ë¹®ÀÚ·Î ÀÌ·ç¾îÁø ´Ü¾î¸¦ ÃßÃâÇÏ´Â Á¤±Ô½Ä s = re.findall('[A-Z]{3}', text) print(s) | cs |