Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 24th, 2001, 02:08 PM
hyrum hyrum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Kitchener, Ontario, Canada
Posts: 31 hyrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 8 sec
Reputation Power: 8
Send a message via ICQ to hyrum
Unhappy Regexp problem...

I'm using the following regexps but they are causing problems. For example: they are adding a space to the beginning of $_ and also making hyphenated words look like:
holy - cow instead of holy-cow

How can I fix this?

foreach (@ads[0..($count-2)]) {


@fList = split (/\|/,$_);
$_=~s/Memo:.*?</</;
$_=~s/\$\@clasNumb:(\d\d\d\d?).*?\@firs:(\d+[a-zA-Z]+\d+)[A-Z]....\d*?([A-Z]{3}).*?\$Diag1(\d+)\w\d+</</;
$clas=$1;
$date=$2;
$code=$3;
$number=$4;
$_=~s/\*.*?>//g;
$_=~s/<.*?>/ /g;
$_=~s/\s+/ /g;
$_=~s/\cC//;
$_=~s/exp(\d+)\.(\d+)//g;
$_=~s/exp(\d+)\.//g;

Reply With Quote
  #2  
Old May 25th, 2001, 10:06 AM
Atrus's Avatar
Atrus Atrus is offline
yet another member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 262 Atrus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hi!

Your line:
$_=~s/\s+/ /g;

The space between the last slashes might be the reason for the starting spaces you wrote about.

(Maybe $_=~s/\s+//g; is what you wanted? Note sure...)


Greetings,

Atrus.

Reply With Quote
  #3  
Old May 25th, 2001, 10:16 AM
hyrum hyrum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Kitchener, Ontario, Canada
Posts: 31 hyrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 8 sec
Reputation Power: 8
Send a message via ICQ to hyrum
That took away the space yes, I missed that completely! It kind of fixed the hyphens as well. Only problem I see is this:

moun-tainbike

Some words had the hyphen in there from going to the next line but they are totally messed up in here. Any suggestions?

Reply With Quote
  #4  
Old May 25th, 2001, 10:32 AM
Atrus's Avatar
Atrus Atrus is offline
yet another member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 262 Atrus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hi!

Give an example of I and O

Regexps are just too difficult to figure out without syntax highlighting :-(


Pleased to help.

Atrus.

Reply With Quote
  #5  
Old May 25th, 2001, 10:37 AM
hyrum hyrum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Kitchener, Ontario, Canada
Posts: 31 hyrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 8 sec
Reputation Power: 8
Send a message via ICQ to hyrum
Here is an exmaple of the input This is a big problem we have here:


$ Diag 1108966V1 !

<sti><nam POS><sv1 0><fu 1><bns><bc >*cbe,99<ec1><bc >*pe<ec1><eol>
<bc >*tfNEWSGO<ec1><fs 81><vbn 271><ps 200><bc >*BF<ec1><fs 83>
<vbn 273><sfv 1><bc >*ps6<ec1><ps 120><bc >*ss6.5<ec1><ss 130><bc >
*la104%<ec1><bc >*cpe<ec1><bc >*cse<ec1><bc >*ih6.<ec1><bc >*bo<ec1><ens><bc >*com<ec1>
<bc ><bn ><nop>Memo: under 50...Kelly<10><ec1><eol>
<ava 90><m 1560><sha 49><ewi 67>BABY <mha>GATE.<bc >*bb<ec1><bns>
<bc >*cpd<ec1><bc >*tfNEWSGO<ec1><fs 81><vbn 271><sfv 0><bc >*ps6.<ec1>
<ss 120><bc >*ss6.5<ec1><ss 130><bc >*la104%<ec1><bc >*fe<ec1><ens> <aha 48>
Plastic. <mha>Excel<bns>-<ens><eol>
<csa 0><ava 124><sha 84><aha 120><ewi 67>lent <mha>condition. <aha 85>
$10. <mha>Call <csa 0><eol>
<ava 124><aha 120><ri 852><ewi 67>579-1178. <bns><bc >*dih<ec1><bc >
*pe<ec1><eol>
<ava 60><ri 12><ewi 67><bc >*lcd<ec1><bc >*add<ec1><bc >*ic<ec1><bc >
*IR.6<ec1><bc >*rs.5<ec1><bc >*la3.<ec1><bc >*rab<ec1><hpr 0><rul 10,1548>
<aha 1548><bc >*ru<ec1><bc >*fe<ec1><ens><ava 30><eol>
0 Okay

$ !@clas Numb:1000 @sort:BABY HIGHC @firs:24may01 L 9B116070 KWR N2K 1N6


It comes out to this:

U|108966|KWR|1000||P|20010523|||BABYGATE.Plastic.Excel-lentcondition.$10.Call579-1178.

Now I did notice a problem by taking out that space, if you view the above output, there are no spaces

Also, the hyphens are a pain!

Reply With Quote
  #6  
Old May 25th, 2001, 10:48 AM
Atrus's Avatar
Atrus Atrus is offline
yet another member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 262 Atrus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hi!

Sorry, you were not quite clear on what the problem concerning the hyphens was.

Concerning missing spaces:
In your longest line...
$_=~s/\$\@clasNumb:(\d\d\d\d?).*?\@firs:(\d+[a-zA-Z]+\d+)[A-Z]....\d*?([A-Z]{3}).*?\$Diag1(\d+)\w\d+</</;

...I find several '.' that match spaces, too, of course. Maybe you should use [^ ] instead of some of them to prevent deletion of all spaces.


Maybe use
[^ ]...
instead of
....


Hope this brings you closer to a solution :-)

Greetings,

Atrus.

Reply With Quote
  #7  
Old May 25th, 2001, 11:43 AM
hyrum hyrum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Kitchener, Ontario, Canada
Posts: 31 hyrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 8 sec
Reputation Power: 8
Send a message via ICQ to hyrum
No luck But I do appreciate your efforts

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Regexp problem...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT