Skip to content

Commit f330c02

Browse files
committed
corrected spaces to tabs snippet
1 parent 51a63b1 commit f330c02

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
This file was deleted.

snippets/java/string-manipulation/spaces-to-tabs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ tags: string,tab,space,conversion
66
---
77

88
```java
9-
public static String convertTabToSpace(String text, int spacesPerTab) {
10-
return text.replaceAll("\t", " ".repeat(spacesPerTab));
9+
public static String convertSpacesToTab(String text, int spacesPerTab) {
10+
return text.replaceAll(" ".repeat(spacesPerTab), "\t");
1111
}
1212

1313
// Usage:
14-
System.out.println(convertTabToSpace("hello\tworld", 2)); // "hello world"
14+
System.out.println(convertSpacesToTab("hello world", 4)); // Output: hello\tworld
1515
```

0 commit comments

Comments
 (0)