Here you can find the source of toSnakeCase(String str)
Parameter | Description |
---|---|
str | a parameter |
public static String toSnakeCase(String str)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .j a v a 2 s . c o m*/ * Convert a string to snake_case * @param str * @return */ public static String toSnakeCase(String str) { return str.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase(); } }