Skip to content

Instantly share code, notes, and snippets.

@waprin
Created August 6, 2014 18:47
Show Gist options
  • Save waprin/ec2e546af4e87f7a4e5b to your computer and use it in GitHub Desktop.
Save waprin/ec2e546af4e87f7a4e5b to your computer and use it in GitHub Desktop.
Concatenate Multi-Line Java String Literals
import fileinput
x = ""
for line in fileinput.input():
x += line
s = ""
i = 1
while i < len(x):
if x[i] == '"':
i += 1
while i < len(x) and x[i] != '"':
i = i + 1
else:
s += x[i]
i += 1
@waprin
Copy link
Author

waprin commented Aug 6, 2014


bill-mbp:~ bill$ cat literal.txt
"SELECT customer as id "
              + "FROM customers "
              + "ON id = order.id "
bill-mbp:~ bill$ python cat_literals.py < literal.txt
SELECT customer as id FROM customers ON id = order.id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment