-1

I wonder if there is a way to make a string uppercase using regex only in JS. The thing is that I am giving my users a string transformation system.

The user supply me with three parameters : original text, replace regex, subtitution regex.

for example:
original : 'stackoverflow'
replace : /([a-z])(.*)/g
subtitution : $1

Result : 's'

I want to give them the abilitty to set the entire string to uppercase. I've noticed in some other SO questions that there are systems that allows that. for example in sublime text you can do '/\U$1/' to set the entire string to uppercase.

Notice: I cannot use toUpperCase or toLowerCase in any way

3
  • No way, JS regex does not support case changing operators. Commented Aug 7, 2017 at 16:09
  • @WiktorStribiżew this is not a duplicate. I am looking for a way to do that without using toLowerCase or toUpperCase. Also an answer saying "there is no way" would be fine Commented Aug 7, 2017 at 16:21
  • There is no way. The answer is given in the linked thread. "No way" is not an answer. Commented Aug 7, 2017 at 16:26

1 Answer 1

0

Javascript has an inbuilt uppercasing method

var str = "Hello World!";
var res = str.toUpperCase();
The result of res will be:

HELLO WORLD!
Sign up to request clarification or add additional context in comments.

1 Comment

I know, but as I mentioned I let my users just supply me with two regexes. They have no access to the 'toUpperCase' method. That is why I asked for regex only solutions

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.