Click here to Skip to main content
15,886,080 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I like to remove underscore only before every (.).How can i do it ?

Input:

DEMO_.config
    DEMO_.html



Expected:

DEMO.config
DEMO.html

What I have tried:

$str =~ tr/a-zA-Z//dc
Posted
Updated 15-Mar-17 22:17pm

1 solution

You can't use a transliteration for this because those operate on characters from a list but you want to match the substring _..

So you have to use a regular expression:
PERL
$str =~ s/_\././g;

s: Search and replace
pattern _\.: underscore and dot (dot must be escaped)
replace with .: dot (escaping can be omitted here)
flags g: global (replace all occurences)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900