For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Search Pattern Question: What does # mean?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Search Pattern Question: What does # mean?
Siegfried Heintze

2005-06-06, 3:56 am

I'm using regular expressions to parse job titles and I had C# in a pattern
and it was not working correctly. I corrected the problem with C\#. What
does C# match?

Thanks,
Sieg

Offer Kaye

2005-06-06, 8:55 am

On 6/6/05, Siegfried Heintze wrote:
> I'm using regular expressions to parse job titles and I had C# in a patte=

rn
> and it was not working correctly. I corrected the problem with C\#. What
> does C# match?
>=20


"#" has no special meaning in REs (it's not a metacharacter), so you
would have to show us some code that fails with the above pattern.
Off-hand I can't think of any reason why "C\#" would match while "C#"
would not.

Regards,
--=20
Offer Kaye
Graeme St.Clair

2005-06-06, 3:56 pm

I think he must be using the x modifier.

p148 of Camel 3rd Edn - "\x allows spaces, tabs and newlines for formatting,
just like regular Perl code. It also allows the # character, not normally
special in a pattern, to introduce a comment that extends through the end of
the current line within the pattern string. If you want to match ... the #
character, then you'll have to ... escape it with a backslash ..."

Rgds, GStC.

----- Original Message -----
From: "Offer Kaye" <offer.kaye@gmail.com>
To: "Perl Beginners" <beginners@perl.org>
Sent: Monday, June 06, 2005 3:14 AM
Subject: Re: Search Pattern Question: What does # mean?


On 6/6/05, Siegfried Heintze wrote:
> I'm using regular expressions to parse job titles and I had C# in a
> pattern
> and it was not working correctly. I corrected the problem with C\#. What
> does C# match?
>


"#" has no special meaning in REs (it's not a metacharacter), so you
would have to show us some code that fails with the above pattern.
Off-hand I can't think of any reason why "C\#" would match while "C#"
would not.

Regards,
--
Offer Kaye

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com