XDR-ENGINEER · Question #18
What will be the output of the function below? L_TRIM("a* aapple", "a")
The correct answer is A. ' aapple'. Option A is correct because L_TRIM scans the string from the left, removing all leading characters that belong to the specified trim set. Here, the trim characters are a and ` (treated as a character set), so the function strips the leading 'a' then '' from "a* aapple"…
Question
What will be the output of the function below? L_TRIM("a* aapple", "a")
Options
- A' aapple'
- B" aapple"
- C"pple"
- D" aapple-"
How the community answered
(49 responses)- A76% (37)
- B14% (7)
- C6% (3)
- D4% (2)
Explanation
Option A is correct because L_TRIM scans the string from the left, removing all leading characters that belong to the specified trim set. Here, the trim characters are a and * (treated as a character set), so the function strips the leading 'a' then '*' from "a* aapple" - stopping at the space, which is not in the trim set - leaving ' aapple' (with a preserved leading space).
Why the distractors are wrong:
- B (
" aapple") appears identical but uses double-quotes; in this context the distinction lies in how the result string is represented - the correct output uses single-quote notation indicating the literal string value. - C (
"pple") would result from removing all'a'characters throughout the entire string, not just from the left - that's the behavior of a global replace, notL_TRIM. - D (
" aapple-") introduces a trailing dash that no trim function would ever append; it's a nonsense distractor.
Memory tip: Think of L_TRIM as a lawn edger working only on the left side - it clips characters one by one from the edge as long as they match the specified set, but stops the moment it hits a non-matching character, leaving everything to the right untouched.
Topics
Community Discussion
No community discussion yet for this question.