You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add Index and LastIndex property to $matches variable #11755
I'm not really sure what you're asking here. What purpose would this serve? $matches is just a hashtable; all it really has is key and value for each item.
I'd also recommend you follow the feature suggestion template we have so that others can more easily understand what exactly it is that you're proposing 😊
Ilya (@iSazonov) thanks, that makes a bit more sense! It does raise the question of whether we want First/LastIndex of just the 0 entry, though, or whether we'd want to add it for each match group entry as well?
Adding new entries to $Matches is also a potentially breaking change.
However, we discussed returning [System.Text.RegularExpressions.Match] instances in the context of a future -allmatches operator - #7867 - which would at least enable you to do:
PS> ('hello' -allmatches 'e')[0]
Groups : {0}
Success : True
Name : 0
Captures : {0}
Index : 1
Length : 1
Value : e
Activity
vexx32 commentedon Feb 2, 2020
I'm not really sure what you're asking here. What purpose would this serve? $matches is just a hashtable; all it really has is key and value for each item.
I'd also recommend you follow the feature suggestion template we have so that others can more easily understand what exactly it is that you're proposing 😊
iSazonov commentedon Feb 3, 2020
It is about first and last position of found substring in source line.
vexx32 commentedon Feb 3, 2020
Ilya (@iSazonov) thanks, that makes a bit more sense! It does raise the question of whether we want First/LastIndex of just the
0entry, though, or whether we'd want to add it for each match group entry as well?iSazonov commentedon Feb 3, 2020
I guess it is based on Regex and we can not add the indexes without performance degradation.
mklement0 commentedon Feb 3, 2020
Adding new entries to
$Matchesis also a potentially breaking change.However, we discussed returning
[System.Text.RegularExpressions.Match]instances in the context of a future-allmatchesoperator - #7867 - which would at least enable you to do:iSazonov commentedon Feb 4, 2020
Michael Klement (@mklement0) Can you move this in #7867 explicitly?
mklement0 commentedon Feb 4, 2020
Assuming you meant my previous comment, Ilya (@iSazonov): done.