No announcement yet.

PHP preg_replace Function

  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP preg_replace Function

    Is there a known issue or constraint using PHP preg_replace in Scriptcase 9.3?

    I want to strip non-numeric characters from phone numbers using preg_replace and then update the table while reviewing new records. Iím getting inconsistent results (sometimes the application compiles, other times not). Iím placing the PHP script within a button and checking to see if the character field has any content. The application has nine phone fields during which most are null, but I want to address all phone fields at the same time.

    if (strlen({Talent_Phone}) > 3) {
    $_Talent_Phone = preg_replace("/[^0-9]/", "", {Talent_Phone});

  • #2
    why not use the 'allow character' to check at input in combination with a fieldmask (eg ##-#####-##)?


    • #3
      Because 99% of the source information comes via API from an external system which I cannot control.


      • #4
        What must be done when strlen({Talent_Phone}) <=3? So what i would do during tests is
        1. to add a ELSE and echo strlen({Talent_Phone} in there. Just to check why php skip the preg_replace.
        2. are you sure this is the correct format (/[^0-9]/)?