digitalmars.D.learn - How to compare strings against static char arrays?
- Andrej Mitrovic (7/7) Apr 26 2011 E.g.:
- Nick Sabalausky (4/12) Apr 26 2011 assert(strip(blue) == "blue");
- Andrej Mitrovic (3/21) Apr 26 2011 Yup. blue[].strip (slice is needed).
- Nick Sabalausky (3/25) Apr 26 2011 Yea, I keep trying to do trim(), too. Hard habit to break :)
- Jonathan M Davis (8/38) Apr 26 2011 That's one of those functions that is quite common among many languages ...
- Nick Sabalausky (5/45) Apr 26 2011 Yup, absolutely. For me, until about a year ago, I had spent a lot of ti...
E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?
Apr 26 2011
"Andrej Mitrovic" <none none.none> wrote in message news:ip7phj$28v5$1 digitalmars.com...E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?assert(strip(blue) == "blue"); Is that what you need or did I misunderstand?
Apr 26 2011
Nick Sabalausky Wrote:"Andrej Mitrovic" <none none.none> wrote in message news:ip7phj$28v5$1 digitalmars.com...Yup. blue[].strip (slice is needed). And here I was desperately trying to find the trim() function. Thanks!E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?assert(strip(blue) == "blue"); Is that what you need or did I misunderstand?
Apr 26 2011
"Andrej Mitrovic" <none none.none> wrote in message news:ip7pqt$29hc$1 digitalmars.com...Nick Sabalausky Wrote:Yea, I keep trying to do trim(), too. Hard habit to break :)"Andrej Mitrovic" <none none.none> wrote in message news:ip7phj$28v5$1 digitalmars.com...Yup. blue[].strip (slice is needed). And here I was desperately trying to find the trim() function. Thanks!E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?assert(strip(blue) == "blue"); Is that what you need or did I misunderstand?
Apr 26 2011
"Andrej Mitrovic" <none none.none> wrote in message news:ip7pqt$29hc$1 digitalmars.com...That's one of those functions that is quite common among many languages but is often not called quite the same thing. So, if you're used to a particular name, and the language chose another, then you're constantly thrown off by it until you use it enough that it sticks. But if they'd picked the name that you're used to, then someone else would have been constantly thrown off instead, since they were used to languages/libraries that used the first name. So, you can't really win. - Jonathan M DavisNick Sabalausky Wrote:Yea, I keep trying to do trim(), too. Hard habit to break :)"Andrej Mitrovic" <none none.none> wrote in message news:ip7phj$28v5$1 digitalmars.com...Yup. blue[].strip (slice is needed). And here I was desperately trying to find the trim() function. Thanks!E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?assert(strip(blue) == "blue"); Is that what you need or did I misunderstand?
Apr 26 2011
"Jonathan M Davis" <jmdavisProg gmx.com> wrote in message news:mailman.3694.1303869505.4748.digitalmars-d-learn puremagic.com...Yup, absolutely. For me, until about a year ago, I had spent a lot of time with Tango, which uses "trim", and I do a lot of work in Haxe which IIRC also uses "trim", so that's why my brain still keeps reaching for "trim"."Andrej Mitrovic" <none none.none> wrote in message news:ip7pqt$29hc$1 digitalmars.com...That's one of those functions that is quite common among many languages but is often not called quite the same thing. So, if you're used to a particular name, and the language chose another, then you're constantly thrown off by it until you use it enough that it sticks. But if they'd picked the name that you're used to, then someone else would have been constantly thrown off instead, since they were used to languages/libraries that used the first name. So, you can't really win.Nick Sabalausky Wrote:Yea, I keep trying to do trim(), too. Hard habit to break :)"Andrej Mitrovic" <none none.none> wrote in message news:ip7phj$28v5$1 digitalmars.com...Yup. blue[].strip (slice is needed). And here I was desperately trying to find the trim() function. Thanks!E.g.: void main() { char[10] blue = "blue "; assert(blue == "blue"); } Obviously these two are different, but what function can I use to compare strings in situations where whitespace is the delimiter?assert(strip(blue) == "blue"); Is that what you need or did I misunderstand?
Apr 26 2011