in reply to character encoding ambiguities when performing regexps with html entities
use strict; use warnings; my $text=q' \Start We have $\alpha$-helical to a $\beta$-sheet proteins and stuff. The $\beta$-sheet structures relate to $\pi$ by several \degrees. '; my %allowed_text_code = ( '$\alpha$' => 'α', '$\beta$' => 'β', '$\gamma$' => 'γ', '$\delta$' => 'δ', '$\theta$' => 'θ', '$\pi$' => 'π', '\degrees' => '°' ); foreach my $tex_key (keys %allowed_text_code) { $text =~ s/\Q$tex_key\E/$allowed_text_code{$tex_key}/g; } print $text. "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: character encoding ambiguities when performing regexps with html entities
by ikegami (Patriarch) on Sep 24, 2007 at 18:05 UTC | |
by mwah (Hermit) on Sep 24, 2007 at 18:14 UTC |