How can I match everything that is after the last occurrence of some char in a perl regular expression?

后端 未结 7 1329
误落风尘
误落风尘 2020-12-18 19:04

For example, return the part of the string that is after the last x in axxxghdfx445 (should return 445).

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 19:48

    the simplest way is not regular expression, but a simple split() and getting the last element.

    $string="axxxghdfx445";
    @s = split /x/ , $string;
    print $s[-1];
    

提交回复
热议问题