regex pattern that matches the string at the end of a string but is not followed by line break
问题 I use a regex pattern i preg_match php function. The pattern is let's say '/abc$/' . It matches both strings: 'abc' and 'abc ' The second one has the line break at its end. What would be the pattern that matches only this first string? 'abc' 回答1: The reason why /abc$/ matches both "abc\n" and "abc" is that $ matches the location at the end of the string, or (even without /m modifier) the position before the newline that is at the end of the string. You need the following regex: /abc\z/ where