Greg --

The pipe | operator isn't single characters only:

$string =~ /this|that|the other/;

But the character set is:

$string =~ /[abc]/; # matches any a, b or c
$string =~ /[tw]hat/; # matches 'that' or 'what'

What you're looking for is something like this:

$string =~ /\\L(ength)?\b/;

That's going to match
- backslash, followed by
- capital "L", followed by
- optional "ength" (question mark after the parens means it's optional),
followed by
- a word break

So "\Lengthy" would NOT match (there's no word break between h and y)
and "\Len." would NOT match (L must be followed by a word break, or 'ength'
and a word break)
and "Length" would NOT match (there's no leading backslash)
but "\L" would match, as would "\Length".

Regular expressions are very powerful and let you match obtuse patterns of
almost any complexity.

In case it helps, years ago I wrote a SQL-focused intro to regular
expressions, which I found here:
http://markmail.org/message/ivvksx5zihkjmpye . Hope this helps!



On Thu, Mar 8, 2012 at 9:32 AM, Greg Aiken <gai...@visioninfosoft.com>wrote:

> in pdf files evidently there are two different ways  one may specify the
> 'length' operator
>
> sometimes one sees;
> \Length
>
> while at other times, the letter L is sufficient;
> \L
>
> i am wanting to do a pattern match for a line of data in a pdf file where
> i am looking to match EITHER \L or \Length
>
> is there a way that using ONE pattern match I can say achieve something
> like this?
>
> in pseudo code:
>    $record =~ /'Length' | 'L'/
> (where the precedence would be towards the first thing matched, in this
> case, 'Length')
>
> the only example ive seen which uses the or operator (|), shows this
> working for a single character only, as in:
>    $record =~ /a|b/
>
> ive never seen an example quite like what I would like to do...
>
> if it cant be currently done, perhaps a future enhancement to regex could
> be in order, by adding a new enclosing 'literal delimiter', something like
> this could one day work (forgive me here, im just thinking outside of the
> box - only as i dont know any better);
>
>    $record =~ /'Length' | 'L'/
>
> thanks for helping me with my understanding of this.
>
> sincerely,
>
> greg
>
>
>
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>


-- 
"We act as though comfort and luxury were the chief requirements of life,
when all that we need to make us happy is something to be enthusiastic
about." -- Albert Einstein
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to