Re: regex help please
- From: "Jerry" <jpreston@xxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Dec 2006 15:02:29 -0600
Paul,
Basicly that is the code except for reading a file:
open ( FI, "$work_path\\$form_file" ) or die "Couldn't open
$work_path\\$form_file";
my @text = <FI>;
close FI;
Yes this is wrong "my $_", I was using "my $str" at first.
This is just a simple way to list my results for debuging my code:
print "parm: *1 $1*2 $2*3 $3*4 $4*6 $6*7 $7*8
$8*$9*$10*$11*$12*$_*<br>\n";
Nothing major going on!
Thanks,
Jerry
"Paul Lalli" <mritty@xxxxxxxxx> wrote in message
news:1167339165.614399.257270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Jerry wrote:
It has been a while that I have done any regex. What I am trying to do
is
break down a string like the following:
my $_ = " Emp# EmpStatus MStatus BeganEmp
EndedEmp";
$_ cannot be lexicalized. Please post real code. Have you read the
posting guidelines that are posted here twice a week? They contain
invaluable information on how to create a good posting that is likely
to be answered.
I do not know many words will be in $_ or if there will be spaces at the
front of $_ or not.
Along the getting the words, I need to get all the spaces as a word
between
the words and at the end as well.
I don't have a clue what this means. What does "all the spaces as a
word between the words" mean? Please post desired output along with
your sample input. This is another thing that's in those guidelines.
I have started with:
/\s+(\w+)\s+/g;
print "parm: *1 $1*2 $2*3 $3*4 $4*6 $6*7 $7*8
$8*$9*$10*$11*$12*$_*<br>\n" ;
And how does the result of this do or not do what you want? Please
post actual output along with desired output and sample input. Again,
this is in the posting guidelines.
As a hunch, I'd say you want to use the split function, splitting on
whitespace, and capturing the delimiter with parentheses, so that the
delimiters are also returned. See
perldoc -f split
And then create a short-but-complete script that demonstrates your best
attempt, along with sample input and output that demonstrates what you
want, what you got, and how they differ.
Paul Lalli
.
- Follow-Ups:
- Re: regex help please
- From: Paul Lalli
- Re: regex help please
- References:
- regex help please
- From: Jerry
- Re: regex help please
- From: Paul Lalli
- regex help please
- Prev by Date: Re: regex help please
- Next by Date: Re: regex help please
- Previous by thread: Re: regex help please
- Next by thread: Re: regex help please
- Index(es):
Relevant Pages
|