9/1/2023 0 Comments Purebasic string extension![]() ![]() Procedure FindStringIndexChris(String.s, StringFind.s, Index.i)ĭefine String. Position = FindString(string, StringFind, Position) If Index > 0 And Not String = "" And Not StringFind = "" Procedure FindStringIndexLord(string.s, StringFind.s, Index.i) *String + LenStringFind * SizeOf(character)ĭebug "FindStringIndex(" + String + ", " + StringFind + ", 2) = " + FindStringIndex(String, StringFind, 2)ĭebug "FindStringIndex(" + String + ", " + StringFind + ", 0) = " + FindStringIndex(String, StringFind, 0)ĭebug "FindStringIndex(" + String + ", " + StringFind + ", 1) = " + FindStringIndex(String, StringFind, 1)ĭebug "FindStringIndex(" + String + ", " + StringFind + ", 3) = " + FindStringIndex(String, StringFind, 3)ĭebug "FindStringIndex(" + String + ", " + StringFind + ", 4) = " + FindStringIndex(String, StringFind, 4) If Index = LenStringFind And CompareMemoryString(*String, *StringFind, #PB_String_CaseSensitive, LenStringFind) = #PB_String_Equal) Protected LenStringFind.i, Find.i, FindIndex.i, Position.i, Exit.i Protected *String.character, *StringFind.character Procedure FindStringIndex(String.s, StringFind.s, Index.i) String.s = "words/are/separated/by/bracketed/delimiters/like/this."ĭebug Find_String_Index(string.s, "/", 2) <- Will return 10ĭebug Find_String_Index(string.s, "/", 5) <- Will return 33ĭebug Find_String_Index(string.s, "/", 7) <- Will return 49ĭebug Find_String_Index(string.s, "/", 8) <- Will return 0 since there are only 7 sub-stringsĭebug Find_String_Index(string.s, "/", 0) <- Test nonsense value, will return 0 ProcedureReturn foundpos.q Return character position where this count foundĭefine string.s = "words()are()separated()by()bracketed()delimiters()like()this."ĭebug Find_String_Index(string.s, "()", 2) <- Will return 11ĭebug Find_String_Index(string.s, "()", 5) <- Will return 37ĭebug Find_String_Index(string.s, "()", 7) <- Will return 55ĭebug Find_String_Index(string.s, "()", 8) <- Will return 0 since there are only 7 sub-stringsĭebug Find_String_Index(string.s, "()", 0) <- Test nonsense value, will return 0 Stpos.q = findpos.q + 1 Set next start position one char on from found pos.įoundpos.q = findpos.q Set the position of the final 'index' occurrenceĭone.b = #True FindString() didn't find, so nothing more to do If findpos.q Found sub-string with position findpos.qįindcnt.q + 1 Increment our occurrence counter While Not(done.b) Loop until exit flag setįindpos.q = FindString(string.s, find.s, stpos.q) Find sub-string with rolling start position stpos Stpos.q = 1 Start at position 1 of string to be searched ![]() If index.q > 0 Index.q value must be at least 1 Procedure.q Find_String_Index(string.s, find.s, index.q)ĭefine findpos.q Running FindString() result for each occurrenceĭefine foundpos.q Found position of n-th occurrenceĭefine findcnt.q Running counter of found sub-stringĭefine stpos.q Running start position for FindString() Quist's later work sees him striving after a sublimated, pure basic form. ![]() ** Find position of n-th occurrence of a sub-string in a string - for example the 3rd "/" in 1/2/3/4/5 would be 6 van Eyck, extensions to Estec, 1989 geving grotendeels prijsgeven vanwege. The last file shows how the Is_Numeric function can be called. package body Numeric_Tests isįunction Is_Numeric (Item : in String) return Boolean is The second file is the package body containing the implementation of the Is_Numeric function. package Numeric_Tests isįunction Is_Numeric (Item : in String) return Boolean The first file is the package interface containing the declaration of the Is_Numeric function. ![]() Public function isNumeric(num:String):Boolean If you want to help to improve and eventually enable this page,Ĭreate a boolean function which takes in a string and tells whether it is a numeric string (floating point and negative numbers included) in the syntax the language uses for numeric literals or numbers converted from strings. Incorrect code, conceptual problems, or other severe issues. This means it might contain formatting issues, ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |