php - Preg match a string to find all encounters of -> using regular expressions -
i'm having small technical difficulty regular expression, i'm trying @ string, let's have string:
$string = "error->400"; and string:
$string = "error->debug->warning"; as example, i'm trying preg_match() returns true on instances of -> within it.
this attempt don't understand why doesn't work:
preg_match("/^[->]*$/", $string); is there general rule custom characters i'm missing?
thanks.
right now, ^[->]*$ matches number of "-" or ">" characters, beginning end. must use group, not character class, , anchors not necessary. use check if "->" present in $string:
preg_match("/(->)/", $string); have @ example.
Comments
Post a Comment