Re: Inserting '-' character in front of all numbers in a string



Paul McGuire wrote:
On Mar 30, 2:09 pm, Michael Bentley <mich...@xxxxxxxxxxxxxxxxx> wrote:

On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote:






I want to be able to insert a '-' character in front of all numeric
values in a string. I want to insert the '-' character to use in
conjunction with the getopt.getopt() function.

' '.join(map(lambda x: '-' + x, s.split()))

assuming that you just want to put a "-" in front of each field,
regardless of its content.

John Nagle
.



Relevant Pages

  • Re: Inserting - character in front of all numbers in a string
    ... I want to insert the '-' character to use in ... conjunction with the getopt.getoptfunction. ... if I input -2a -3ab as my string. ... accepting the string input first, then adding in the '-' character ...
    (comp.lang.python)
  • Re: Inserting - character in front of all numbers in a string
    ... I want to insert the '-' character to use in ... conjunction with the getopt.getoptfunction. ... if I input -2a -3ab as my string. ... accepting the string input first, then adding in the '-' character ...
    (comp.lang.python)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)