in reply to can't find mistake. using sort and slice in regex
One thing I might try to change in your code is to replace your sort line with this:
as using sort just for retrieving the largest of two variables seems a bit of an overkill. I think that the intent gets clearer. But this will probably produce the same result. So we are back to my first question: where is it wrong?s/(\d+)(?= (\d+))/ $1 > $2 ? $1 : $2/eg;
Update: I had not seen that the line I suggested just above was in your commented out code lines. I tried the code as you have it and also with the code line suggested just above, they seem to produce the same output.
|
|---|