I am trying to extract a relatively simple pattern out of each line
in a file but come up with wierd results. I think I got lucky and
made an expression that works but do not understand why it does not
work in a simpler method. Both methods are below.
SAMPLE:
T01c.001 F001 S40
T02 C.002F002 S40
T03C.003F003 S40
T04 C.004 F004 S40
T05F005c.005 S40
T06 F006 c.006 S40
Perl pattern Search:
t\d+\D*.*c.(\d\d\d\d|\d\d\d|\d\d|\d)\D+.+.$
Replaces with:
C.$1
Output (desired):
C.001
C.002
C.003
C.004
C.005
C.006
I dont understand why the S&R pattern below does not work.
Perl pattern Search:
t\d+\D*.*c.(\d+).*
Replaces with ("-" used to troubleshoot/see capture):
C.-$1-
Output (undesired):
C.-0-01 F001 S40
C.-0-02F002 S40
C.-0-03F003 S40
C.-0-04 F004 S40
C.-0-05 S40
C.-0-06 S40
Please explain why the capture is not getting the whole set of digits
and why the end of the like is not dropping off.
Thanks so much!!