php regular expression assistance bold a filename
I am not very good, with regular expression开发者_如何学JAVA in php I am trying to get a reg_expression to find all file names such as /file-name-here.php and make it bold.
This expression works in Flash but not in php it also doesn't accept the '-' i'm not sure why i can't get it to work with preg_replace
/(https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?/g
I think you need to escape your forward slashes:
/(https?:\/\/)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((\/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?/g
Or you could use a different delimiter (in PHP, the first character is the delimiter for the regular expression):
@(https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?@g
精彩评论