Dear Monks,
I have a situation where I have a string of data which contains essentially encoded html text, and could really be any size. I then take that string and substring it. Once that is done I use a regular expression to search and replace the html encoded tags. I then use another regular expression to attempt to chop off any unclosed html encoding that might be left at the end of the string. To make a long story short my code appears to be working, however I'm sure there is a way to refactor my regular expressions perhaps into a single statement. Any help would be highly appreciated.
Example Code
$string = substr($incoming, 0, 177);
$string =~ s/\<\;?[-.a-zA-Z0-9]*.*?\>\;//gs; #This does a great j
+ob axing anything basically that starts with a < and ends with a >
$string =~ s/\<\;?[-.a-zA-Z0-9]*.*$//gs; #Due to my substring there
+ is sometimes an open bracket such as <img src...chomp
Is there any way to combine the two regex examples? Thanks again.
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;
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.