casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
17.59k stars 399 forks source link

clarify the `matching pat` in replacement documentation #1983

Open nyurik opened 1 month ago

nyurik commented 1 month ago

String manipulation contains this section which is not very clear. Does pat refer to an exact string match, e.g. removing trim_end_match("foobar", "bar") would result in "foo", or does it support some pattern matching (as the variable name would imply)? I tried it with regex, but it seems like it is not working.

trim_end_match(s, pat) - Remove suffix of s matching pat.
trim_end_matches(s, pat) - Repeatedly remove suffixes of s matching pat.
trim_start_match(s, pat) - Remove prefix of s matching pat.
trim_start_matches(s, pat) - Repeatedly remove prefixes of s matching pat.
laniakea64 commented 1 month ago

It's an exact string match. These functions call Rust functions for these jobs, passing them the pat parameter string as-is:

https://github.com/casey/just/blob/d3d0dbef7df9c9a2e6be1c57114e526ff0d42985/src/function.rs#L429-L435 https://github.com/casey/just/blob/d3d0dbef7df9c9a2e6be1c57114e526ff0d42985/src/function.rs#L441-L447