Add replace method to LicenseExpression
Closed this issue · 5 comments
pombredanne commented
I would like to replace a expression and by another expression in a given expression.
The semantics should be the same as the string.replace
stdlib function eg:
string.replace(s, old, new[, maxreplace])
Return a copy of string s with all occurrences of substring old replaced by new.
If the optional argument maxreplace is given, the first maxreplace occurrences are replaced.
e.g. the function should apply to all exact sub expressions matching old in the expression tree and should not be recursive like in string.replace
:
>>> 'foobarbar'.replace('foobar', 'foo')
'foobar'
The maxreplace is not needed.
pombredanne commented
See also this bastikr/boolean.py#66
pombredanne commented
The subs method in bastikr/boolean.py#66 is all we need and this is already there.
I am adding some tests to verify that this works as expected.
yash-nisar commented
@pombredanne I think this has been fixed, so can we close this ? Please correct me if I am wrong. :)
yash-nisar commented
Ping @pombredanne
pombredanne commented
@yash-nisar good catch. Thanks! closing.