Title says it all really, heres some sample code anyway.
@name Rep Test
print(">"+"Hi":replace("",""))
Empty string matches any character. Try string.find("hello","")
Empty string matches any character. Try string.find("hello","")
Why is this relevant? Only reason this returns an empty string is because here we return an empty string if given an empty needle.
That check can be removed as it won't crash anymore. Or it could be changed to just return the string itself, would do the same as calling string.Replace except skips that step.
Strange that "" matches anything, do you think we could get it to just return the input as techically replacing any char with itself should't change anything.
https://github.com/wiremod/wire/blob/master/lua/entities/gmod_wire_expression2/core/string.lua#L313-L317
This is an anti-crash feature.
@TomyLobo Do you not agree that it still should return itself and not an empty string? Also I've already said that it won't crash anymore,
That check can be removed as it won't crash anymore. Or it could be changed to just return the string itself, would do the same as calling string.Replace except skips that step.
@TomyLobo
Can you tell what exactly can crash if this is removed, because I see only 邪 value assign. Moreover. Just a return statement. The interpreter will not even go trough the "this:Replace( needle, new)" statement.
@bigdogmat i was just stating a fact, not implying an opinion.
Most helpful comment
@bigdogmat i was just stating a fact, not implying an opinion.