-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
| Previous ID | SR-1003 |
| Radar | None |
| Original Reporter | swift-studies (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
Ubuntu 15.10
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Foundation |
| Labels | Bug, Linux |
| Assignee | @pushkarnk |
| Priority | Medium |
md5: 0292be96ae89e0648973a601f0bf1ce6
Issue Description:
The following code example only matches once on Linux, but works as expected on OS X
import Foundation
let text = " * Item 1\n * Item 2\n * Item 3\n * Item 4\n * Item 5\n * Item 6\n"
let pattern = "(\\n)?(^[ \\t]*)([*-])[ \\t]+((?s:.+?)(\\n{1,2}))(?=\\n*(\\z|\\2([*-])[ \\t]+))"
if let regex = try? NSRegularExpression(pattern:pattern,options:[NSRegularExpressionOptions.AnchorsMatchLines]){
//Template replacement
var mutableString = NSMutableString(string:text)
regex.replaceMatchesInString(mutableString, options: NSMatchingOptions(), range: NSMakeRange(0,text.characters.count), withTemplate: "Matched: $4")
//Print result
print(mutableString)
}Expected output is
Matched: Item 1
Matched: Item 2
Matched: Item 3
Matched: Item 4
Matched: Item 5
Matched: Item 6
But on Linux the template is only applied once (same is true when enumerating with blocks only one match is returned)
Matched: Item 1
* Item 2
* Item 3
* Item 4
* Item 5
* Item 6