Ian Macalinao
Ian Macalinao

Reputation: 1668

Regex uppercase

I have a list of strings like this:

purpcl ("purpose clause modifier"),
quantmod ("quantier modifier"),
rcmod ("relative clause modifier"),

Is it possible to make them like this:

PURPCL ("purpose clause modifier"),
QUANTMOD ("quantier modifier"),
RCMOD ("relative clause modifier"),

Upvotes: 2

Views: 743

Answers (2)

João Silva
João Silva

Reputation: 91309

It is possible with some tools, such as sed:

$ sed -r 's/^([^(]+)/\U\1/'
purpcl ("purpuse clause modifier"),
PURPCL ("purpuse clause modifier"),

But you should definitely not use regular expressions for this kind of processing.

Upvotes: 2

Bart Kiers
Bart Kiers

Reputation: 170158

Some languages (like Perl) and/or editors (or IDE's) have such features, but in general, no, that is not possible with regex alone.

And only changing the letter that are outside of string literals is already stretching the capabilities of regex.

Upvotes: 0

Related Questions