@@ -30,23 +30,23 @@ function capitalize(str: string) {
3030 * @param {string } str
3131 */
3232function hasSymbols ( str : string ) {
33- return / [ ! " # % & ' ( ) * + , . / : ; < = > ? @ [ \\ \] ^ ` { | } ] / u. exec ( str ) // without " ", "$", "-" and "_"
33+ return / [ ! " # % & ' ( ) * + , . / : ; < = > ? @ [ \\ \] ^ ` { | } ] / u. test ( str ) // without " ", "$", "-" and "_"
3434}
3535
3636/**
3737 * Checks whether the given string has upper.
3838 * @param {string } str
3939 */
4040function hasUpper ( str : string ) {
41- return / [ A - Z ] / u. exec ( str )
41+ return / [ A - Z ] / u. test ( str )
4242}
4343
4444/**
4545 * Checks whether the given string has lower.
4646 * @param {string } str
4747 */
4848function hasLower ( str : string ) {
49- return / [ a - z ] / u. exec ( str )
49+ return / [ a - z ] / u. test ( str )
5050}
5151
5252/**
@@ -70,8 +70,8 @@ export function isKebabCase(str: string): boolean {
7070 if (
7171 hasUpper ( str ) ||
7272 hasSymbols ( str ) ||
73- / ^ - / u . exec ( str ) || // starts with hyphen is not kebab-case
74- / _ | - - | \s / u. exec ( str )
73+ str . startsWith ( "-" ) || // starts with hyphen is not kebab-case
74+ / _ | - - | \s / u. test ( str )
7575 ) {
7676 return false
7777 }
@@ -96,7 +96,7 @@ export function snakeCase(str: string): string {
9696 * @param {string } str
9797 */
9898export function isSnakeCase ( str : string ) : boolean {
99- if ( hasUpper ( str ) || hasSymbols ( str ) || / - | _ _ | \s / u. exec ( str ) ) {
99+ if ( hasUpper ( str ) || hasSymbols ( str ) || / - | _ _ | \s / u. test ( str ) ) {
100100 return false
101101 }
102102 return true
@@ -120,7 +120,7 @@ export function screamingSnakeCase(str: string): string {
120120 * @param {string } str
121121 */
122122export function isScreamingSnakeCase ( str : string ) : boolean {
123- if ( hasLower ( str ) || hasSymbols ( str ) || / - | _ _ | \s / u. exec ( str ) ) {
123+ if ( hasLower ( str ) || hasSymbols ( str ) || / - | _ _ | \s / u. test ( str ) ) {
124124 return false
125125 }
126126 return true
@@ -149,8 +149,8 @@ export function camelCase(str: string): string {
149149export function isCamelCase ( str : string ) : boolean {
150150 if (
151151 hasSymbols ( str ) ||
152- / ^ [ A - Z ] / u. exec ( str ) ||
153- / - | _ | \s / u. exec ( str ) // kebab or snake or space
152+ / ^ [ A - Z ] / u. test ( str ) ||
153+ / - | _ | \s / u. test ( str ) // kebab or snake or space
154154 ) {
155155 return false
156156 }
@@ -173,8 +173,8 @@ export function pascalCase(str: string): string {
173173export function isPascalCase ( str : string ) : boolean {
174174 if (
175175 hasSymbols ( str ) ||
176- / ^ [ a - z ] / u. exec ( str ) ||
177- / - | _ | \s / u. exec ( str ) // kebab or snake or space
176+ / ^ [ a - z ] / u. test ( str ) ||
177+ / - | _ | \s / u. test ( str ) // kebab or snake or space
178178 ) {
179179 return false
180180 }
0 commit comments