Hi I'm a little stuck,

I'm trying to write a small script that will pull uld numbers from a given String when provided with the prefix and suffix.

They will always end with EK and can start with AKE, PLA, PMC etc

For the life of me though I don't know where to start.

I would greatly appreciate and help thanks.

    The [man]strings[/man] functions would be a good place to start. There is, for example, a function that takes [man]substr[/man]ings.

      Weedpacket;11043113 wrote:

      The [man]strings[/man] functions would be a good place to start. There is, for example, a function that takes [man]substr[/man]ings.

      The best function I can see if SSCANF()

      But it's returning a single empty array?

      $cpm = "
      CPM
      EY301/01.A6EYJ.
      -11L/N-11R/N
      -12L/PLA1133R7/DAM/1500/C .RFL-12R/N
      -21L/AKE/2001R7/DAM/500/C-21R/AKE2244R7/DAM/500/C 
      -22P/PAG1657R7/DAM/2300/C.PER 
      -23P/PMC7645R7/DAM/3500/C.RFL 
      -24P/PAJ1934R7/AMM/1705/C 
      -31L/AKE2547R7/AMM/450/M.RFL-31R/AKE5543R7/AMM/500/C 
      -32L/AKE5522R7/AMM/600/BY-32R/AKE1132R7/AMM/680BY 
      -33L/AKE0033R7/DAM/ 680/BY-33R/AKE4468R7/DAM/680/BY 
      -41L/AKE0221R7/DAM/600/BC-41R/AKE5713R7/DAM/680/BT 
      -42L/AKE8674R7/DAM/500/BF-42R/N
      -43L/N-43R/N
      -51/AUH/100/C.AVI
      -52/N
      -53/N
      ";
      
      
      
      $id = Sscanf($cpm, "{%[A-Z]%d%[A-Z]%[0-9]}");
      
      Print_r ($id);
      

      Output

      Array
      (
      [0] =>
      [1] =>
      [2] =>
      [3] =>
      )

        You'll want to check the documentation for the format used by [man]sscanf[/man] - it's not a regular expression (which you could use instead if you want).

          Write a Reply...