P
Pat
Hi,
I have a big input file full of words, whitespace, newlines, punctuation,
and various other symbols. I want to surround every word with quotes,
UNLESS it already has quotes around it.
After some trial and error, I was seeing some unexpected results. The
closest I came to getting it right was this:
my $str = ' "these" "have" "quotes" these do not. ';
$str =~ s/([^"a-zA-Z0-9_])([a-zA-Z0-9_]+)([^"a-zA-Z0-9_])/$1"$2"$3/gs;
And the result is this:
"these" "have" "quotes" "these" do "not".
The only problem is that "do" is skipped. Is this expected? So how do I
get around this?
Thanks.
I have a big input file full of words, whitespace, newlines, punctuation,
and various other symbols. I want to surround every word with quotes,
UNLESS it already has quotes around it.
After some trial and error, I was seeing some unexpected results. The
closest I came to getting it right was this:
my $str = ' "these" "have" "quotes" these do not. ';
$str =~ s/([^"a-zA-Z0-9_])([a-zA-Z0-9_]+)([^"a-zA-Z0-9_])/$1"$2"$3/gs;
And the result is this:
"these" "have" "quotes" "these" do "not".
The only problem is that "do" is skipped. Is this expected? So how do I
get around this?
Thanks.