Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function StringMatches:Int(text:String,search:String)
- ' --- special comparison function with wildcards and stuff ---
- If search.Length = 0 Return False
- If text = search Return True
- 'do wildcard check
- 'split search term into tokens
- Local tokens:String[] = search.Split("*")
- If tokens.Length = 1 Return False
- 'do a scan
- Local cursorX:Int = 0
- Local Pos:Int
- For Local index:Int = 0 Until tokens.Length
- Pos = text.Find(tokens[index],cursorX)
- If Pos = -1 Return False
- cursorX = Pos + tokens[index].Length
- Next
- Return True
- End Function
- Local text:String="hello world how are you"
- Local search:String = "*world"
- If StringMatches(text,search)
- Print "YAY MATCH :D '"+text+"' search with '"+search+"'"
- Else
- Print "NO MATCH :( '"+text+"' search with '"+search+"'"
- EndIf
Add Comment
Please, Sign In to add comment