need help for a regex. thanks a lot!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Shi

    need help for a regex. thanks a lot!

    The pattern is required as:

    "Item purchased: [text, can be many workds] (Item #[at least 10 digits
    number])"

    Here is an example:

    "Item purchased: Intel Pentium IV 3G CPU (Item #23467893452)"


    Thanks in advance!

    Alex

  • kingofkolt

    #2
    Re: need help for a regex. thanks a lot!

    $string = "Item purchased: Intel Pentium IV 3G CPU (Item #23467893452)";
    if (preg_match("/Item purchased: ([\w\s]+) \(Item
    #(\d{10,})\)/",$string,$arra y)) {
    print "<pre>";
    print_r($array) ;
    print "</pre>";
    }

    "Alex Shi" <chpshi@stonix. com> wrote in message
    news:ny0hc.1175 8$ga5.7286@nntp-post.primus.ca. ..[color=blue]
    > The pattern is required as:
    >
    > "Item purchased: [text, can be many workds] (Item #[at least 10 digits
    > number])"
    >
    > Here is an example:
    >
    > "Item purchased: Intel Pentium IV 3G CPU (Item #23467893452)"
    >
    >
    > Thanks in advance!
    >
    > Alex
    >[/color]


    Comment

    • Alex Shi

      #3
      Re: need help for a regex. thanks a lot!

      Thanks!
      [color=blue]
      > $string = "Item purchased: Intel Pentium IV 3G CPU (Item #23467893452)";
      > if (preg_match("/Item purchased: ([\w\s]+) \(Item
      > #(\d{10,})\)/",$string,$arra y)) {
      > print "<pre>";
      > print_r($array) ;
      > print "</pre>";
      > }
      >
      > "Alex Shi" <chpshi@stonix. com> wrote in message
      > news:ny0hc.1175 8$ga5.7286@nntp-post.primus.ca. ..[color=green]
      > > The pattern is required as:
      > >
      > > "Item purchased: [text, can be many workds] (Item #[at least 10 digits
      > > number])"
      > >
      > > Here is an example:
      > >
      > > "Item purchased: Intel Pentium IV 3G CPU (Item #23467893452)"
      > >
      > >
      > > Thanks in advance!
      > >
      > > Alex
      > >[/color]
      >
      >[/color]

      Comment

      Working...