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

后端 未结 7 1340
误落风尘
误落风尘 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 20:04

    the first answer is a good one, but when talking about "something that does not contain"... i like to use the regex that "matches" it

    my($substr) = $string =~ /.*x([^x]*)$/;

    very usefull in some case

提交回复
热议问题