我找到YAPE::Regex::Explain
模塊非常有益的 -
C:\>perl -e "use YAPE::Regex::Explain;print YAPE::Regex::Explain->new(qr/['-])->explain;"
The regular expression:
(?-imsx:['-])
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with^and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
['-] any character of: ''', '-'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
C:\>perl -e "use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/(\w+), ?(.)/)->explain;"
The regular expression:
(?-imsx:(\w+), ?(.))
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with^and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
, ','
----------------------------------------------------------------------
? ' ' (optional (matching the most amount
possible))
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
. any character except \n
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
C:\>
你應該去與康拉德的解決方案(後我固定它)。那個人很容易理解。 – 2008-12-19 15:00:44
哦,我不知道你已經修好了......我會測試它,謝謝......儘管Vinko的解決方案對我來說工作很好。我不知道你是否看到了我們的評論帖子,但他幫助擺脫了字符串中的其他字符。我會告訴你,如果你的作品,謝謝。 – CheeseConQueso 2008-12-19 15:04:16
它將Parisi,Kenneth變成kparisienneth
$ rowfetch =〜s /(\ w +),\ s(\ w)/ $ 2 $ 1 /;
$ rowfetch =〜s /([a-z] +)\ s([a-z])/ $ 2 $ 1/i;
$ rowfetch = lc $ rowfetch; – CheeseConQueso 2008-12-19 15:16:07