Differences between version 5 and revision by previous author of RegularExpression.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 5 | Last edited on Friday, March 14, 2003 12:04:34 pm | by JohnMcPherson | Revert |
Older page: | version 2 | Last edited on Monday, March 10, 2003 2:19:00 am | by AristotlePagaltzis | Revert |
@@ -84,4 +84,21 @@
/[[\W]/ is equivalent to /[[^a-zA-Z0-9_]/
/[[\S]/ is equivalent to /[[^ \r\t\n\f]/
+----
+!Perl
+
+As mentioned before, perl uses an extended regular expression syntax explained on the perlre(1) man page.
+
+Having said that though, here are some hints.
+
+__DON'T__ interprete variables as a regular expression
+
+if we have
+ $text='abc[[c]defc';
+ $search='[[c]';
+then
+ $text =~ s/\Q$search\E/XX/ ;
+would replace the substring '[[c]' in $text with "XX", while
+ $text =~ s/$search/XX/ ;
+would replace all the occurrences of the character 'c' with "XX".