Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 859a0bd

Browse files
author
Troy Melhase
committed
Merge pull request natural#18 from iuliux/master
Added regex sub rule for String.format
2 parents fa8a410 + d5103ae commit 859a0bd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

java2python/config/default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
moduleOutputSubs = [
190190
(r'System\.out\.println\((.*)\)', r'print \1'),
191191
(r'System\.out\.print_\((.*?)\)', r'print \1,'),
192+
(r'String\.format\(\"(.*)\" *, *(.*)\)', r'"\1" % (\2)'),
192193
(r'(.*?)\.equals\((.*?)\)', r'\1 == \2'),
193194
(r'(.*?)\.equalsIgnoreCase\((.*?)\)', r'\1.lower() == \2.lower()'),
194195
(r'([\w.]+)\.size\(\)', r'len(\1)'),

test/Format.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Format {
2+
public static void main(String[] args) {
3+
int i = 22;
4+
String s = "text";
5+
String r = String.format("> (%d) %s", i, s);
6+
7+
System.out.println(r);
8+
}
9+
}

0 commit comments

Comments
 (0)