[rt-users] Searching for a string

Nathan Cutler presnypreklad at gmail.com
Fri Aug 9 09:27:34 EDT 2013


> I am searching the content of an email for a string using.
>
> m/'Building: Walgreen Drug Store #\d+/  Does not find text.
>
> But
>
> index($t_subject, 'Building: Walgreen Drug Store #'); Does find text.

A few (hopefully helpful) questions:

1. Why do have a single-quote character before the word Building in
the first example, but not in the second?

2. Can you send an example string that you searching over?

3. Better yet, can you send a snippet of your code?

And a note: if you are trying to capture text, you need parentheses
around the text you intend to capture. Something like this:

<CODE>
#!/usr/bin/perl
use strict;
use warnings;

my $str="And suddenly, there were Building: Walgreen Drug Store
#235232343434324235521 flies in the tepid air";

my ($substr) = ($str =~ m/(Building: Walgreen Drug Store #\d+)/);
print $substr, "\n";
</CODE>

Also, you don't mention whether this string occurs only in the email
headers, or also in the body? If in the body, will you have to deal
with the possibility of a line break occuring inside the string?

Nathan



More information about the rt-users mailing list