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

后端 未结 7 1310
误落风尘
误落风尘 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

    0 讨论(0)
提交回复
热议问题