Guest Posted February 23, 2011 Share Posted February 23, 2011 If I had the pattern: $pattern = "/^[a-zA-Z0-9._-]{4,20}$/"; And I wanted to replace, 4, 20 with a variable, how would I go about doing so? Link to comment https://forums.phpfreaks.com/topic/228620-a-variable-inside-of-a-pattern-possible/ Share on other sites More sharing options...
silkfire Posted February 23, 2011 Share Posted February 23, 2011 Like this?: $var = '5,19'; $pattern = '/^[a-zA-Z0-9._-]{' . $var . '}$/'; Link to comment https://forums.phpfreaks.com/topic/228620-a-variable-inside-of-a-pattern-possible/#findComment-1178764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.