-3

I want to capitalise everything following a _ using regex.

Example: from en_gb to en_GB

Thanks!

nnnnnn
  • 147,572
  • 30
  • 200
  • 241
  • 1
    This isn't a code writing service - how far have your own efforts got you? – Clive May 13 '13 at 12:12
  • 2
    I think that sounds like a good project for a beginner to tackle on their own while learning. –  May 13 '13 at 12:13

2 Answers2

7

I know you should have tried some effort, but I am being nice on a Monday morning with a cup of coffee in my hand.

Use a replace function and use the argument to transform the string.

"en_gb".replace(/_.*/,function(a){return a.toUpperCase();})
epascarello
  • 204,599
  • 20
  • 195
  • 236
1

This will should change change all after the underscore to uppercase. Tested works

var str="en_gb";
var splitStrg=str.split("_");
splitStrg[1] = splitStrg[1].toUpperCase();
var str = splitStrg.join("_");
dc5553
  • 1,243
  • 11
  • 21