Wow, I'm impressed by how fast I got three awesome replies here, thanks to all of you so far.
"This is presuming that your elements to match are single characters as in the example, however."
Argh, I'm really sorry, I should've picked a better example here, I forgot about tr/// when choosing the 'a' and 'b' one.
In my real life issue I want to replace
every \bi\b with a 'you',
every \byou\b with an 'i',
every \bu\b with an 'i',
every \byour\n with a 'my',
every \bmy\b with a 'your',
every \bam\b with an 'are',
every \bare\b with an 'am',
and every \br\b with an 'am'.
"i think you really should've picked a better example for your perlmonks thread"
=>
"you think i really should've picked a better example for my perlmonks thread"
I'm really sorry for the poor example in my inital post.
Thanks guys.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.