Mindsword has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I have been working on a code for work and I found an odd glitch in my regular expression. I am looking through several blocks of texts for the Titles of some documents. The first title is "Screening Ligands by X-ray Crystallography." The text with that clearly has Screening Ligands by X-ray Crystallography in it. However, my regualr expression (below) does not pick it up. I have removed the 40 lines of code before this for brevities sake.
However, if I do the code below, I do get a match.#!/usr/bin/perl use warnings; use strict; use feature qw(say); ... ... if ($text =~ /Screening Ligands by X ray Crystallography/) { say "MATCH!"; } else { say "NOPE!"; } }
I have narrowed down the issue to the "-" I think. However, I can't search for the titles without the "-" as maybe 2/3rds of them have it. Any thoughts on how to get around this?if ($text =~ /Screening Ligands by/) { say "MATCH!"; } else { say "NOPE!"; } }
EDIT: Based on what you all wrote, I began looking at a few of the others that were failing and have proven its not the "-" Its still not working correctly, but I at least know its not what I thought. I may even know what the issue is, but I'll need to run some tests. I think it may be an issue from the original titles not matching what's actually in the document.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression Hiccup
by hdb (Monsignor) on May 04, 2015 at 20:48 UTC | |
|
Re: Regular Expression Hiccup
by Corion (Patriarch) on May 04, 2015 at 19:40 UTC | |
|
Re: Regular Expression Hiccup
by GotToBTru (Prior) on May 04, 2015 at 20:22 UTC | |
|
Re: Regular Expression Hiccup
by graff (Chancellor) on May 05, 2015 at 04:53 UTC | |
|
Re: Regular Expression Hiccup
by Laurent_R (Canon) on May 04, 2015 at 20:18 UTC | |
|
Re: Regular Expression Hiccup
by Anonymous Monk on May 04, 2015 at 19:50 UTC | |
by Mindsword (Initiate) on May 04, 2015 at 20:21 UTC | |
by AnomalousMonk (Archbishop) on May 04, 2015 at 21:46 UTC | |
by jeffa (Bishop) on May 04, 2015 at 21:17 UTC |