regex - Rails: truncate string after match -
say i've got string so:
"this belongs there's other keyword else." how truncate it'd find keyword , truncate keyword else. give me only:
"this belongs there's other " thanks!
1.9.3p327 > str = "this belongs there's other keyword else." => "this belongs there's other keyword else." 1.9.3p327 > str.sub(/keyword.*/, '') => "this belongs there's other " be careful though match on "keywordwithnotrailingspace". \b getting word boundaries...
Comments
Post a Comment