Method: String#strip!
- Defined in:
- string.c
#strip! ⇒ self?
Like String#strip, except that any modifications are made in self; returns self if any modification are made, nil otherwise.
Related: String#lstrip!, String#strip!.
10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 |
# File 'string.c', line 10403 static VALUE rb_str_strip_bang(VALUE str) { char *start; long olen, loffset, roffset; rb_encoding *enc; str_modify_keep_cr(str); enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); loffset = lstrip_offset(str, start, start+olen, enc); roffset = rstrip_offset(str, start+loffset, start+olen, enc); if (loffset > 0 || roffset > 0) { long len = olen-roffset; if (loffset > 0) { len -= loffset; memmove(start, start + loffset, len); } STR_SET_LEN(str, len); TERM_FILL(start+len, rb_enc_mbminlen(enc)); return str; } return Qnil; } |