Skip to content

Commit d532525

Browse files
committed
tab/space conversion snippets
1 parent 93a89b7 commit d532525

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Title: Spaces To Tabs
3+
description: Converts spaces into tabs
4+
author: Mcbencrafter
5+
tags: string,tab,space,conversion
6+
---
7+
8+
```java
9+
public static String convertTabToSpace(String text, int spacesPerTab) {
10+
return text.replaceAll("\t", " ".repeat(spacesPerTab));
11+
}
12+
13+
// Usage:
14+
System.out.println(convertTabToSpace("hello\tworld", 2)); // "hello world"
15+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Title: Tabs To Spaces
3+
description: Converts tabs into spaces
4+
author: Mcbencrafter
5+
tags: string,tab,space,conversion
6+
---
7+
8+
```java
9+
public static String convertTabToSpace(String text, int spacesPerTab) {
10+
return text.replaceAll("\t", " ".repeat(spacesPerTab));
11+
}
12+
13+
// Usage:
14+
System.out.println(convertTabToSpace("hello\tworld", 2)); // "hello world"
15+
```

0 commit comments

Comments
 (0)