#!/usr/bin/perl use strict; use warnings; my $test_string = "foo l?est sé?jou ? foo "; $test_string =~ s/(?<!\s)\?(?!\s)/'/sig; print "$test_string\n";
The expression will fail when the character before ((?<!...)) the question mark is white space and when the character after ((?!...)) the question mark is white space. This will substitute if there is a leading or trailing question mark. These are zero-width assertions, so you don't have to worry about capturing. See perlre for details.
In reply to Re: Simple regex question
by kennethk
in thread Simple regex question
by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |