|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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; |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
||||
|
||||
|
Hi!
Give an example of I and O Regexps are just too difficult to figure out without syntax highlighting :-( Pleased to help. Atrus. |
|
#5
|
|||
|
|||
|
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! |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
No luck
But I do appreciate your efforts ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Regexp problem... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|