Hi Monks :-)
I have another regex question: I have a small and a large text. The small text is just a part of the larger one.
For example:
$text1 = 'A company (IBM) made a profit of $300 in the current year.'
+;
$text2 = 'Latest profit news: A company (IBM) made a profit of $300 i
+n the current year. This is 180% more than in the last year.';
I'd like to replace the small text in the larger one. Now my problem is that the smaller text contains various characters that are used in regexes "()$." and
that this regex
$text2 =~ s/($text1)/FOO$1BAR/;
doesn't seem to work ...
Is there any workaround ?
Many thanks for your help !
Dany
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.