faqts : Computers : Programming : Languages : Tse : Search

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

TSE: String: Search: How to find the position of a single character in a string?

Nov 7th, 2006 15:15
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 07 November 2020 - 10:04 pm -------------------
TSE: String: Search: How to find the position of a single character in 
a string?
---
Method:
Use e.g. the inbuilt function Pos()
which you supply the string (or character) you
are searching for and the string you will search in.
It will then return the position of this character
when found, otherwise zero.
--- cut here: begin --------------------------------------------------
INTEGER PROC FNStringSearchInstrI( STRING containS, STRING searchS )
 RETURN( Pos( searchS, containS ) )
END
PROC Main()
 Message( FNStringSearchInstrI( "ABCDFG", "C" ) ) // gives 3, as this 
is "C" can be found in the 3th position in the string
END
<F12> Main()
--- cut here: end ----------------------------------------------------
===
Method: Use the StrFind() function
TSE v4.x
This is similar to Pos(), but here you can
search with regular expressions if necessary.
===
Internet: see also:
---
----------------------------------------------------------------------