Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - Regular Expression problem

 
Thread Tools Search this Thread
Old 07-20-2003, 06:16 PM   #1
Default Regular Expression problem


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
  Reply With Quote
Old 07-20-2003, 08:11 PM   #2
Shawn Corey
 
Posts: n/a
Default Re: Regular Expression problem

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!


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump