Grant Edwards wrote:
> On 2021-02-14, Mr Flibble wrote:
>> On 14/02/2021 21:14, Chris Green wrote:
>>> What's the easiest way to change the first occurrence of a specified
>>> character in a string?
>>
>> By using a grown up (i.e. non-toy) programming language.
>
>
>
> [gotta love slrn's scori
On 2021-02-14, Mr Flibble wrote:
> On 14/02/2021 21:14, Chris Green wrote:
>> What's the easiest way to change the first occurrence of a specified
>> character in a string?
>
> By using a grown up (i.e. non-toy) programming language.
[gotta love slrn's scoring feature...]
--
https://mail.pyth
On 14/02/2021 21:14, Chris Green wrote:
What's the easiest way to change the first occurrence of a specified
character in a string?
By using a grown up (i.e. non-toy) programming language.
/Flibble
--
😎
--
https://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
> On 2021-02-14 21:14, Chris Green wrote:
> > What's the easiest way to change the first occurrence of a specified
> > character in a string?
> >
> > E.g. I want to change linux-raid.vger.kernel.org to
> > linux-r...@vger.kernel.org, it's a fairly general requirement of
> > needing to
Gary Herron wrote:
>
> On 2/14/21 1:14 PM, c...@isbd.net wrote:
> > What's the easiest way to change the first occurrence of a specified
> > character in a string?
> >
> > E.g. I want to change linux-raid.vger.kernel.org to
> > linux-r...@vger.kernel.org, it's a fairly general requirement of
> >
The string type has a replace function that does what you want.
Except you can't change a string -- they are immutable -- so this
creates a new string.
>>> s = 'linux-raid.vger.kernel.org'
>>> new_s = s.replace('.', '@', 1)
>>> new_s
'linux-r...@vger.kernel.org'
On 2/14/21 1:14 PM, c...@isb
with_at = with_dots.replace(".", "@", 1)
https://docs.python.org/3/library/stdtypes.html#str.replace
--Ned.
On Sunday, February 14, 2021 at 4:18:22 PM UTC-5, Chris Green wrote:
> What's the easiest way to change the first occurrence of a specified
> character in a string?
>
> E.g. I want to c
On 2021-02-14 21:14, Chris Green wrote:
What's the easiest way to change the first occurrence of a specified
character in a string?
E.g. I want to change linux-raid.vger.kernel.org to
linux-r...@vger.kernel.org, it's a fairly general requirement of
needing to change '.' to '@'.
Alternatively is
Check out re.sub's "count" parameter.
https://stackoverflow.com/questions/3951660/how-to-replace-the-first-occurrence-of-a-regular-expression-in-python
On Sun, Feb 14, 2021 at 1:20 PM Chris Green wrote:
> What's the easiest way to change the first occurrence of a specified
> character in a stri
What's the easiest way to change the first occurrence of a specified
character in a string?
E.g. I want to change linux-raid.vger.kernel.org to
linux-r...@vger.kernel.org, it's a fairly general requirement of
needing to change '.' to '@'.
Alternatively is there an RE 'match' function that would t
10 matches
Mail list logo