Make characters lower and replace specified character

Contents

Output

a_b_c


Code examples


JavaScript

let str = "A-B-C";
console.log(str.replace(/-/g, "_").toLowerCase());

PHP

<?php
$str = "A-B-C";
echo strtolower(preg_replace("/-/", "_", $str))."\n";

Perl

my $str="A-B-C";
$str=~ s!-!_!gs;
print lc($str)."\n";

Python

str = "A-B-C"
print(str.replace("-", "_").lower())

Ruby

str = "A-B-C"
print(str.gsub("-", "_").downcase+"\n")