September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,15 @@
|
|||
// version 1.0.6
|
||||
|
||||
val r = Regex("""(/\*.*\*/|//.*$)""")
|
||||
|
||||
fun stripComments(s: String) = s.replace(r, "").trim()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val strings = arrayOf(
|
||||
"apples, pears // and bananas",
|
||||
" apples, pears /* and bananas */",
|
||||
"/* oranges */ apples // pears and bananas ",
|
||||
" \toranges /*apples/*, pears*/*/and bananas"
|
||||
)
|
||||
for (string in strings) println(stripComments(string))
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
# Strip comments
|
||||
echo "$1" | sed 's/ *[#;].*$//g' | sed 's/^ *//'
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fcn strip(text,c){ // if c in text, remove it and following text
|
||||
if (Void!=(n:=text.find(c))) text=text[0,n];
|
||||
text.strip() // remove leading and trailing white space
|
||||
}
|
||||
fcn stripper(text,a,b,c,etc){ // strip a,b,c,etc from text
|
||||
foreach c in (vm.arglist[1,*]){ text=strip(text,c) }
|
||||
text
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
fcn stripper(text,a,b,c,etc){
|
||||
vm.arglist[1,*].reduce('wrap(text,c){
|
||||
if (Void!=(n:=text.find(c))) text[0,n] else text
|
||||
},text)
|
||||
.strip()
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
String(">", strip(" apples, pears # and bananas","#"), "<").println();
|
||||
String(">", stripper(" apples, pears ; and # bananas","#",";"), "<").println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue