ocehb: (Default)
[personal profile] ocehb
разобрать строку, типа 'arg1, "arg2, arg3", arg4' на 'arg1', '"arg2, arg3"' и 'arg4'.
аргументы могут быть любыми.



  DB<1> $a = q|arg1, "arg2, arg3", arg4|
  DB<2> p join "\n",($a =~ m#("[^"]+"|[^,]+),?\s*#g)
arg1
"arg2, arg3"
arg4
  DB<3>


если добавить в качестве ограничителей еще и "'", то:


  DB<3> $a = q|arg1, "arg2, arg3", arg4,'arg6,arg7'|

  DB<4> p join "\n",($a =~ m#("[^"]+"|'[^']+'|[^,]+),?\s*#g)
arg1
"arg2, arg3"
arg4
'arg6,arg7'
  DB<5>


про экранирование буду думать завтра.

Date: 2006-04-19 06:43 am (UTC)
From: [identity profile] jerom.livejournal.com
Это уже было в ru_regexp

Profile

ocehb: (Default)
ocehb

January 2021

S M T W T F S
     12
345 6789
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 7th, 2026 02:11 pm
Powered by Dreamwidth Studios