Link to home
Start Free TrialLog in
Avatar of lrr81765
lrr81765

asked on

RegEx replace upper case

Given
Sum(ItemOne + ItemTwo + ItemThree)
CalcLate( something0

I need to have javascript that would look at all of the characters before the ( and replace them with toLower().

I'd like to do this with the replace (regex, replacement) but can't seem to get the regex to work.

ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here the RegExp version:

<script>

myText = "Sum(ItemOne + ItemTwo + ItemThree)\nCalcLate( something0";

alert(myText.replace(/\w+\s*\(/g,function(p){return p.toLowerCase()}));

</script>

Why is this question still open? Do you need more help or some explanations?