Created
June 24, 2021 17:07
-
-
Save me2beats/0967b96347581037f5dc1518c6f782ee to your computer and use it in GitHub Desktop.
code utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# not tested!! | |
extends Object | |
class_name CodeUtils | |
static func code_line_split(s:String)->PoolStringArray: | |
var res: PoolStringArray | |
var regex: = RegEx.new() | |
regex.compile("\\w+|\\W") | |
var found:Array = regex.search_all(s) | |
for i in found: | |
res.append(i.get_string()) | |
return res | |
static func code_line_split1(s:String)->PoolStringArray: | |
var res: PoolStringArray | |
var regex: = RegEx.new() | |
regex.compile("\\w+|\\s+|\\W") | |
var found:Array = regex.search_all(s) | |
for i in found: | |
res.append(i.get_string()) | |
return res | |
static func get_words_and_punct(text:String)->PoolStringArray: | |
var res: = PoolStringArray() | |
res = code_line_split1(text) | |
# for i in range(res.size()-1, -1, -1): | |
# var stripped = res[i].lstrip(" ") | |
# | |
# if stripped: | |
# res[i] = stripped | |
# else: | |
# res.remove(i) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment