Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Jim Gibson
At 2:16 PM -0500 11/14/10, shawn wilson wrote: so, if you've got a file, do something like: while ($line = ) { $line =~ m/^(.+)$/ig; print "$1<\/s>\n"; } If all you want to do is print each line in the file surrounded by tags, you don't need regular expressions, and you don't need to esca

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Rob Dixon
On 14/11/2010 19:04, Zachary Brooks wrote: What happened when I used the code -- $hello =~ s/^(.+)$/\1<\/s>/gis; -- is that is properly marked and the beginning of the sentence and at the end of the sentence, but then it only worked for one sentence. Any suggestions on getting to appear at t

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
so, if you've got a file, do something like: while ($line = ) { $line =~ m/^(.+)$/ig; print "$1<\/s>\n"; } On Sun, Nov 14, 2010 at 1:53 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > sw> second, why not use a place holder like someone recommended yesterday? > sw> somethin

Re: Perl, pattern matching, substitution

2010-11-14 Thread Rob Dixon
On 14/11/2010 13:53, Zachary Brooks wrote: Hey Rob, Of all the feedback. yours was the one I was able to drop into my code and make it work, no matter how rudimentary my understanding of Perl is. Thanks. You're welcome. I'm glad to be able to help. As far as the XML libraries, we are suppose

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Zachary Brooks
What happened when I used the code -- $hello =~ s/^(.+)$/\1<\/s>/gis; -- is that is properly marked and the beginning of the sentence and at the end of the sentence, but then it only worked for one sentence. Any suggestions on getting to appear at the beginning of every sentence and to appea

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
On Sun, Nov 14, 2010 at 1:53 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > sw> second, why not use a place holder like someone recommended yesterday? > sw> something like: > sw> s/^(.+)$/\1<\/s>/g > > what is a placeholder? nothing like that in regexes. what you have there >

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> second, why not use a place holder like someone recommended yesterday? sw> something like: sw> s/^(.+)$/\1<\/s>/g what is a placeholder? nothing like that in regexes. what you have there is a backreference and used in the wrong place. \1 is meant to b

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Shawn H Corey
On 10-11-14 11:42 AM, Zachary Brooks wrote: $hello = "This is some sample text."; $hello =~ s/^..//gi; $hello =~ s/..$/<\/s>/gi; print "$hello\n"; *is is some sample tex* The meta-character '.' matches every character except a newline. The first substitution replaces 'Th' with ''. The sec

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
On Sun, Nov 14, 2010 at 11:42 AM, Zachary Brooks wrote: > Hello again, > > Yesterday I had a question on pattern matching. A couple of people > responded > with very useful information. After some finagling, I got my rudimentary > code to work. I'm a PhD student studying computational linguistics

Perl, pattern matching, substitution, replacing

2010-11-14 Thread Zachary Brooks
Hello again, Yesterday I had a question on pattern matching. A couple of people responded with very useful information. After some finagling, I got my rudimentary code to work. I'm a PhD student studying computational linguistics without any formal programming training. While there are various mod

Re: Perl, pattern matching, substitution

2010-11-13 Thread Rob Dixon
On 13/11/2010 18:42, Zachary Brooks wrote: Hello, I'm taking a PhD course that requires the use of Perl and pattern matching. I've taken on the motto "divide and conquer," but it hasn't quite worked. I appreciate anyone's help. The task is to extract sentences from a relatively large text file

Re: Perl, pattern matching, substitution

2010-11-13 Thread Sheppy R
I've had similar issues and the \Q \E flags didn't fix it. One thing I've done to fix an issue where regex metacharacters are being caught is to do a replace on all of the characters to include a \ right in front. Something like this: open (my $FILE, "<", $file) or die "$!\n"; my @lines = <$FILE

Re: Perl, pattern matching, substitution

2010-11-13 Thread Shawn H Corey
On 10-11-13 01:42 PM, Zachary Brooks wrote: 1. My first approach was to use substitute to get rid of a range of things between and. A short version looks like this. $hello = " man at the bar order the"; $hello =~ s/.*<\/DATELINE>//gi; print "$hello\n"; I was about to say that you should use

Perl, pattern matching, substitution

2010-11-13 Thread Zachary Brooks
Hello, I'm taking a PhD course that requires the use of Perl and pattern matching. I've taken on the motto "divide and conquer," but it hasn't quite worked. I appreciate anyone's help. The task is to extract sentences from a relatively large text file (928K, ca. 300 pages). But of course, the tex