Hi,

I'm trying to do a regex like this:

if ($summary =~ /\Q[[$article_name]]\E(.*)([^[]+)/s) {

Basically, I have a string:

my $summary_test = q|[sommaire France] [[France]] [[Cities of France]] == Paris blabla == Bordeau blabla === Hotels in Bordeaux blabla [[Things to see in France]] [[Things to do in France]] [/sommaire]|;


As a test (example), what I want to do - is match:

[Cities of France]
...all content, up to the next [[

The above regex kinda works, appart from it grabs ALL the content, to the end of the string (and not the [[ bit)

I'm a little new with the [^[] format - so I expect its something stupid Im doing wrong.

Any pointers would be much appreciated :)

TIA

Andy

In reply to Regex to catch UP TO a particular string? 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.