https://bugzilla.wikimedia.org/show_bug.cgi?id=38944

       Web browser: ---
             Bug #: 38944
           Summary: Previewed regex differs from actual replacement
           Product: MediaWiki extensions
           Version: REL1_19 branch
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: ReplaceText
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified
   Mobile Platform: ---


The preview of the replacement to be made by the following
regex does not match what is actually replaced.

      Original text: Document Number=(POL|PRO) [0-9]+\.([0-9]+)
   Replacement text: $2

The original texts are of the form:

    Document Number=POL 1.23
    Document Number=PRO 23.5
    Document Number=PRO 2.9

and so on.  The idea is to be left with:

    Document Number=23
    Document Number=5
    Document Number=9

i.e. strip what are actually document types and manual section
numbers, and leave only what's after the dot.  The regex I gave
above, when previewed with these original values, only highlights:

    Document Number=POL 1.2
    Document Number=PRO 23.5
    Document Number=PRO 2.9

That is, it is not being greedy about the numbers after the dot, 
but it is being so with the numbers before it.  I tried removing 
the nongreedy-ing 'U' in

    $targetStr = "/$target/U";

in SpecialReplaceText.php extractContext(), and it correctly highlighted 
the whole thing.  But I haven't really read though the ramifications 
of doing that.

Anyway, the point is that when I actually *run* the replacement
(with unmodified code) the correct, greedy, replacement *is* made!

I hope this all makes sense.  :-)  Thanks!

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to