REGEX | SoloLearn: Learn to code for FREE!

+3

REGEX

Can anybody explain me this regex step by step? String output = output.replaceAll("(?<=[^//b^])([A-Z])", "_$1").toLowerCase();

2/15/2020 12:01:41 PM

Mateusz Jurkiewicz

1 Answer

New Answer

+1

output must be initialised before use it, so String output = "ABCDEFGHX /X/XbX^X"; output = output.replaceAll("(?<=[^//b^])([A-Z])", "_$1").toLowerCase(); System.out.println(output); ([A-Z]) () catch to group $1 [A-Z] upper case character of ALPHABET (?<=[^//b^]) (?<= ) but before it, (positive lookBehind) [^ ] can't be (character, but not one of this..) //b^ one of this characters: / or / or b or ^ .replaceAll(this.., with "_$1") _$1 _ and something in catch group $1 .toLowerCase() convert everything to lower case