pattern matching with special char 
Author Message
 pattern matching with special char

Hello!

How can i search for a pattern like

$pattern='bin/c++';
$_ = '/usr/global/bin/c++';
if (m#$pattern#) print "Congratulations\n);

without perl tells me :

/bin/c++/: nested *?+ in regexp at p21 line 22, <in> line 1.

What can i do,that $pattern will be not interpreted.

thanks in advanche
&& sorry for bad english

bert

--
/\/\/\Bert Mueller/\/\/\/\/\/\/\/\/\/\/\/||\/\<Enjoy the silence!>/\/
\/\/\/University of Chemnitz, Germany/\/\||/\/\==================/\/\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/||\/\/\/\/\/\/\/\/\/\/\/\/\/



Sat, 06 Jan 1996 19:10:45 GMT  
 pattern matching with special char

Quote:
(Bert Mueller) writes:
> What can i do,that $pattern will be not interpreted.

$pattern='bin/c++';
$pattern =~ s/(\W)/\\$1/g;  #Camel-Book page 27
$_ = '/usr/global/bin/c++';
print "Congratulations\n" if (m#$pattern#) ;

Gruesse aus Berlin



Sat, 06 Jan 1996 21:39:27 GMT  
 pattern matching with special char

   How can i search for a pattern like

   $pattern='bin/c++';
   $_ = '/usr/global/bin/c++';
   if (m#$pattern#) print "Congratulations\n);

print "Congratulations\n" if (rindex($_, $pat));

print "Just another Perl hacker," unless (rindex($_, ""));
--

"When the only tool you have is Perl, the whole | "Hooray for snakes!"
 world begins to look like your oyster." -- Me  |  -- The Simpsons (29 Apr 93)



Sun, 07 Jan 1996 04:14:57 GMT  
 pattern matching with special char


Quote:
>> print "Congratulations\n" if (rindex($_, $pat));

If you want to find the pattern at the beginning of the line:

print "Congratulations\n" if (rindex($_, $pat) >= $[);

--utashiro (|| $[ = 1)



Sun, 07 Jan 1996 22:27:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Replacing special chars with special chars

2. Special Pattern Match

3. match regexp pattern in a special context?

4. Pattern Matching -- problem with special characters (

5. -- Pattern Matching Special Characters Question! --

6. How can I pattern match a dos formated string (ctrl-m chars)

7. How Do You Pattern Match For \n Char?

8. multi-char pattern with other patterns

9. Match any char EXCEPT [char]

10. Shell special chars in file names?

11. escape special chars before loading into MySQL

12. Special chars

 

 
Powered by phpBB® Forum Software