fork download
  1. <?php
  2.  
  3. $re11='/=(?=[A-Z])|(?<=[A-Z])=/';
  4. $re12= '/=(?=[a-z0-9_\'-])|(?<=[a-z0-9_\'-])=/';
  5. $re = '/=(?=[\w\'-])|(?<=[\w\'-])=/';
  6. $str = 'I\'ve got a many web APP=. My app= is not working fast. It\'= slow app=';
  7.  
  8.  
  9. echo "\n #### condition 1: all contexual upper or lowercase s \n";
  10. $subst = 'S';
  11. $result = preg_replace($re11,'S', $str);
  12. $result = preg_replace($re12,'s', $result);
  13. echo $result;
  14.  
  15.  
  16.  
  17.  
  18. echo "\n ##### condition 2: all small case s \n";
  19. $subst = 's';
  20. $result = preg_replace($re, $subst, $str);
  21. echo $result;
  22.  
  23. echo "\n ##### condition 3: all upper case S \n";
  24. $subst = 'S';
  25. $result = preg_replace($re, $subst, $str);
  26. echo $result;
  27.  
  28. ?>
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
 #### condition 1: all contexual upper or lowercase s 
I've got a many web APPS. My apps is not working fast. It's slow apps
 ##### condition 2: all small case s 
I've got a many web APPs. My apps is not working fast. It's slow apps
 ##### condition 3: all upper case S 
I've got a many web APPS. My appS is not working fast. It'S slow appS