I need to match a string something like
$filecontents = test-app-ref-Man_pub_aut_art_1234;
My regex is something like this but it doesn't work: Can someone help me with the regex 开发者_如何转开发what I am doing wrong here. Please note that I am reading the complete file as a string and this is one of the strings.
while($filecontents =~ m/(test)(-|_)(.*)(_\d{4,})$/isgm){
print " String10 : '$1$2$3$4'\n";
}
looks like you're expecting the string to end with 4 digits, but your string actually ends with 4 digits, then a semi-colon. add a semi-colon before the $
Try this one, worked for me in Excel
(-|_)?.*_\d{4}
Result for the given string:
test-app-ref-Man_pub_aut_art_1234
精彩评论