I want to remove all punctuation from beginning and end of a string except hyphen,underscore.
Example:if input is spice-b32.
Or lg_b32;
Then string after using preg_replace(); should be: spice-b32
and lg_b32
;
i'm also tried to use preg_match('/^[A-Za-z0-9]/',$inm)
for data validation use $inm=preg_replace('/^\PL+|\PL\z/','',$inm);
but, when input a!-read_
result is a!-read
but output should be: a-read
if this preg_replace() OR preg_match() is not correct,then plz help..