sloppyhack
Technical User
I need to be able to truncate at least a specific number of characters to make a string meet a character length requirement. But..I have to truncate on a delimiter (a pipe in this instance) so the string still makes sense.
Example:
I need to remove at least 30 characters from the end of this string..up to a pipe. The regex I would think would work is "[|].{30,}?$". According to documentation..the "?" after the "{30,}" should make it "non-greedy" and match at least 30 characters until it reaches the first pipe. It doesn't seem to be working. It's being greedy and matching up to the first pipe instead of where I would expect.
TEST|TESTTESTTEST|TEST|TESTTESTTEST|TESTTESTTEST
^Matching here ^Want to match here
Any help would be greatly appreciated.
Cheers,
Sloppyhack
Example:
I need to remove at least 30 characters from the end of this string..up to a pipe. The regex I would think would work is "[|].{30,}?$". According to documentation..the "?" after the "{30,}" should make it "non-greedy" and match at least 30 characters until it reaches the first pipe. It doesn't seem to be working. It's being greedy and matching up to the first pipe instead of where I would expect.
TEST|TESTTESTTEST|TEST|TESTTESTTEST|TESTTESTTEST
^Matching here ^Want to match here
Any help would be greatly appreciated.
Cheers,
Sloppyhack