Regular Expression problem

Discussion in 'Perl' started by godfather2, Jul 20, 2003.

  1. godfather2

    godfather2 Guest

    I'm having a regular expression issue that I need some help with. I
    have a string which looks something like this

    "25 A 24 A AA A 99 A CC"

    I need to take the 2 character elements and put them into an array,
    and each 2 character code is separated by " A " (i.e., space A space).
    I have been using a Split function something like this:

    Split(strTemp, " A ")

    but I came across the above string which has an "AA" 2 character code,
    and instead of getting "AA" as an element in the array, I got:

    "AA A 99"

    I don't understand why the space A space expression is not working!
    Any ideas?

    Thanks!
    godfather2, Jul 20, 2003
    #1
    1. Advertising

  2. godfather2

    Shawn Corey Guest

    I don't understand what Split(strTemp, " A ") means. To do your split, try:

    split /\s+A\s+/, $strTemp;

    godfather2 wrote:

    > I'm having a regular expression issue that I need some help with. I
    > have a string which looks something like this
    >
    > "25 A 24 A AA A 99 A CC"
    >
    > I need to take the 2 character elements and put them into an array,
    > and each 2 character code is separated by " A " (i.e., space A space).
    > I have been using a Split function something like this:
    >
    > Split(strTemp, " A ")
    >
    > but I came across the above string which has an "AA" 2 character code,
    > and instead of getting "AA" as an element in the array, I got:
    >
    > "AA A 99"
    >
    > I don't understand why the space A space expression is not working!
    > Any ideas?
    >
    > Thanks!
    Shawn Corey, Jul 20, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,269
  2. Nazir
    Replies:
    3
    Views:
    5,049
    jayendra gadhavi
    Jan 2, 2008
  3. Dan

    Regular expression problem

    Dan, Apr 15, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    415
    Lars Netzel
    Apr 15, 2004
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    831
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,921
    vforvikash
    Dec 29, 2008
Loading...

Share This Page