Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. regex replace single match from right of string
  2. PREG_REPLACE("/(b{$abbr}b)/i", "$long" , $street_address)
  3.        
  4. $str = "123 St Martin St";
  5. $abbr="(b)St(b)";
  6. $long="Street";
  7. var_dump(preg_replace("~$abbr(?!.*?$abbr)~", "$1" . $long . "$2", $str));
  8.        
  9. string(20) "123 St Martin Street"
  10.        
  11. PREG_REPLACE("/(.*(b{$abbr}b.*)*)b{$abbr}b/i", "$1$long" , $street_address )