Re: Keep only one part of a string



le 15/09/2006 01:43, Eero Saynatkari nous a dit:
Zouplaz wrote:
Hello, how to better write that : self.ident = self.ident[/0-9*/]

I'm pretty sure there is a String method that would keep only the first
match of the regex but I didn't found it in the String doc reference

ri String#slice, ri String#slice!

Thanks



Fine ! Thanks... About the same topic (Strings) I wonder how to replace
"REF:90 REFERAL".gsub!('REF:','')
by something else

I tried with .delete but

"REF:90 REFERAL".delete!("REF:") delete every R, E or F char in the string


How to use delete ?

Thanks in advance
.



Relevant Pages

  • Re: Rexex replace
    ... I don't know what you intend the "'$" ... but as far as I know it won't be anything useful in Regex. ... there is an apostrophe there that I didn't see and it ... The String method will be much more ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Rexex replace
    ... tshad wrote: ... I don't think it's the same as "find all instances of the '$' character". ... I think probably you want "\$" as your expression, but of course there remains the question of why use Regex when the String.Replacemethod already does exactly what you want. ... The String method will be much more efficient too. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Keep only one part of a string
    ... Zouplaz wrote: ... I'm pretty sure there is a String method that would keep only the first ... match of the regex but I didn't found it in the String doc reference ...
    (comp.lang.ruby)
  • Keep only one part of a string
    ... I'm pretty sure there is a String method that would keep only the first match of the regex but I didn't found it in the String doc reference ...
    (comp.lang.ruby)