Hi, I'm trying to write a bit of regex, which will got through a list of tags like [something] , and convert to their correct article_id (kinda like a wiki) The code I have is:
# for tags like [[something]] while ($post_message =~ m%\[\[([^]]+)\]\]%gix) { if ($1 =~ /\|/) { next; } my $tmp = $1; my $val = $1; # print STDERR "\n\nFOO\n\n"; if ($DB->table('Articles')->count( { article_title => $tmp } ) > 0 +) { print TESTOUT "\n\nFOO 2 - gggg - $tmp \n\n"; my $article_id = $DB->table('Articles')->select( ['article_id' +], { article_title => $tmp } )->fetchrow; $tmp =~ tr{&[]ÀÂÄàâäÇçÉÊÈËéêèëÏÌÎïìîÖÔÒöôòÜÛÙüûùA-Z?!;«»()" }{ + aaaaaacceeeeeeeeiiiiiioooooouuuuuua-z _}; $tmp =~ s/ /_/g; $post_message =~ s/\Q[[$1]]/[[$article_id]]/sig; } else { ` # do something here latest } }
..but it keeps on looping over and over the same stuff (untl the script dies, or I kill the process in SSH) An example post is:
==Introduction== A Montréal, il y a [[vieux Montréal]]. [[Montréal]] [[test]] ==Brief History== asdfasfd as df asf d asdf as fd asf dasfd ==Geography== ==Regions== ==Cities== ==Sights and Activites== ==Weather== ==Getting There== ==END Getting There==
Can anyone suggest why it keeps doing this kinda stuff: FOO 2 - gggg - vieux Montréal FOO 2 - gggg - Montréal FOO 2 - gggg - vieux Montréal FOO 2 - gggg - 45 FOO 2 - gggg - vieux Montréal FOO 2 - gggg - 47 FOO 2 - gggg - vieux Montréal FOO 2 - gggg - 48 FOO 2 - gggg - vieux Montréal TIA! Andy

In reply to Regex keeps looping on itself :/ by ultranerds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.