2

I wish there was a simple utility that would do this, as regular expressions scare me. I'd like to update the following to preg_replace() if anyone could explain to me how.

eregi_replace('([a-zA-Z0-9_]{'.$min_char.','.$max_char.'})','', $password)

Thanks for any help.

Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
  • 1
    As a general rule, as long as the POSIX regex isn't using any of the `[:WACKY:][:CHARACTER:][:CLASS:]` syntax, you can just add delimiters and have it work in PCRE without too much trouble. [Here's the PCRE manual page on differences between it and POSIX](http://us2.php.net/manual/en/reference.pcre.pattern.posix.php). – Charles Apr 12 '11 at 21:03
  • Thanks, I'll try to remember that. My only fear is knocking something off and not testing it enough to notice. Thankfully this is a fairly simple one, though. – Chuck Le Butt Apr 12 '11 at 22:22

1 Answers1

3

Should be just

/([a-zA-Z0-9_]{$min_char,$max_char})/

preg_replace('/([a-zA-Z0-9_]{'.$min_char.','.$max_char.'})/','', $password)

As far as I can see only the delimiter are missing.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173