【问题标题】:Right truncate of attribute to string of length 40 in perl在perl中将属性右截断为长度为40的字符串
【发布时间】:2021-02-14 09:49:42
【问题描述】:

我想在 Perl 中使用正则表达式将属性值右截断为长度为 40 的字符串。

我尝试不使用正则表达式,只使用substr(),但它不起作用。

$attribute = substr ($attribute , -1 ,40);

【问题讨论】:

  • 为了将来参考,“它不起作用”是描述问题的一种非常不恰当的方式。对于这个问题,您可以考虑使用预期结果与实际结果。

标签: perl substr


【解决方案1】:

“右截断”等于使用substr()通常的方式:

$attribute = substr($attribute,0,40)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-12
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 2011-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多