I have a file name in this format,
remote_execute___jenkin%.java
remtoe__plat_jenk.java
I want to replace all occurance of two or three _
with single _
,
which I have done like this,
re.sub('_{2,3}','_',name)
this works and replace all occurrence of two or three _
with single _
. But in the same re.sub
call, i need to replace .java
with .jav
,
I did this to match both .java
and underscores
,
\.java$|_{2,3}
but how can I replace .java
in the same re.sub
call without using another re.sub
after replacing underscores
,
right now i am doing it like this,
name = re.sub('_{2,3}','_',name)
name = re.sub('\.java$','jav',name)
I want to do above in one re.sub
call