Re: Keep only one part of a string



Zouplaz wrote:

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

What something else? Please say specifically what you want to accomplish.
Post an example string before you apply your desired remedy, and after.


I tried with .delete but

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


How to use delete ?

You are asking how to apply a particular solution, but without first stating
a problem. Maybe the problem is better solved using a different method.

--
Paul Lutus
http://www.arachnoid.com
.



Relevant Pages

  • Re: shBrowseForFolder procedure run issue
    ... You don't mention specifically if you're using the PIDL or string method, ... BrowseForFolderByPath as the initial path): ... I have used the VB6 Package and deployment Wizard and also the Visual ...
    (microsoft.public.vb.controls)
  • Re: WebClient Problem
    ... I've worked A LOT with the web client, in fact, have a whole web site ... > public string UploadValuesToSecureWebsite(string URL, string Username, ... > at System.Net.WebClient.UploadValues(String address, String method, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Accepting text input
    ... The inputfunction evaluates user input as an expression: if he types 2+5 the inputfunction returns the integer 7. ... I would never use inputin a program - it's way too unsafe; ... raw_inputreturns a string, so you can use methods of a string. ... So the .lowerstring method is just to convert the string to lowercase letters so that you don't have to type a bunch of if - then statements in both cases, ...
    (comp.lang.python)
  • Re: SPAM-LOW: Re: Function/method returning list of chars in string?
    ... I should have known - you use a string method to get a list of words, ... but you have to go to the list to get a list of characters from a string. ... Strings support the sequence protocol (aka interface), hence they can be given as input to the list constructor. ...
    (comp.lang.python)
  • Re: String initialization
    ... String str = null; ... IOW, a logic error with the first case may cause you to invoke a String method before you assign an object reference to "str", but in the second case you might set the variable to null before invoking a method. ...
    (comp.lang.java.programmer)