[英]help parsing values using perl regular expression
I'm stuck trying to figure out the perl regex to extract the following values: (the /home/mail/dump dirs will always be the same). 我一直试图找出perl正则表达式来提取以下值:(/ home / mail / dump dirs将始终相同)。 Thanks.
谢谢。
abc
123456
This is the output: 这是输出:
drwxr-xr-x - mail_hd mail_users 0 2011-03-26 20:12 /home/mail/dump/abc
drwxr-xr-x - mail_hd mail_users 0 2011-04-15 09:10 /home/mail/dump/123456
The following perl regex will give just the characters after the final forward slash. 下面的perl正则表达式将仅在最后的正斜杠后给出字符。
s=.*/==
Example: 例:
$ echo 'wxr-xr-x - mail_hd mail_users 0 2011-03-16 18:46 /home/mail/dump/abc' | perl -pe 's=.*/=='
abc
Maybe this is usefull, should return what you need. 也许这很有用,应该退还您所需要的。
if ($subject =~ m!/home/mail/dump/(.*)$!) {
$result = $1;
} else {
$result = "";
}
it matches everything after /home/mail/dump/
until end of line 它匹配
/home/mail/dump/
之后的所有内容,直到行尾
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.